FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   convert integer into string
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: convert integer into string  (Read 14484 times)
bren

WWW Email
convert integer into string
« on: Aug 15th, 2003, 11:45am »

Can someone tell me the method to convert an integer into a string: for instance to display the hours and minutes using the text() method.
 
Cheers.
 
mKoser

WWW Email
Re: convert integer into string
« Reply #1 on: Aug 15th, 2003, 12:22pm »

you can do it like this:
 
Code:

int num = 9;
String str = Integer.toString(num);

 
or as a working example in Proce55ing:
Code:

int num = 9;
String str;
 
void setup(){
}
 
void mousePressed(){
  str = Integer.toString(num);
  println(str);
}

 
- Mikkel
« Last Edit: Aug 15th, 2003, 12:24pm by mKoser »  

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
youhou


Re: convert integer into string
« Reply #2 on: Aug 15th, 2003, 1:10pm »

i guess this should work too :
 
int    iMyInt   = 125;
string strMyInt = ""+ iMyInt;
 
can also be used directly
 
println(""+ iMyint);
 
bren

WWW Email
Re: convert integer into string
« Reply #3 on: Aug 15th, 2003, 3:45pm »

that's great thanks
 
Pages: 1 

« Previous topic | Next topic »