Language \ Environment \ Comparison
 
Index
 
  The Processing 1.0 _ALPHA_ Reference is a work in progress.
If you see any errors or have any comments, please write to: reas at groupc.net
Name  

join()

   
Examples  
// works identically with float[] and String[] 
int list[] = new list[3]; 
list[0] = 8; 
list[1] = 67; 
list[2] = 5; 
String formatted = join(list, ", "); 
// formatted now contains "8, 67, 5" 
 
// to format the number of digits used 
// the '3' means to pad with zeroes up to 3 digits 
String withzeroes = join(list, " ", 3); 
// withzeros now contains "008 067 005" 
 
// for floats, formatting is more complicated because 
// there are also digits after the decimal point. 
float f[] = new float[3]; 
f[0] = 1.3; 
f[1] = 92.8; 
f[2] = 0.7; 
// 3 digits on the left of the decimal point 
// 2 digits to the right of the decimal point 
String zerofloats = join(f, " ", 3, 2); 
// zerofloats now contains "001.30 092.80 007.70" 
 
// or if you don't want to pad the left-hand side 
// a zero will say to ignore and don't pad 
String lesspadding = join(f, " ", 0, 2); 
// lesspadding now contains "1.30 92.80 7.70" 
 

Description   Combines an array of elements into one String.
   
Syntax  
join(anyArray, separator)
join(intArray, separator, digits)
join(floatArray, separator, left, right)
   
Parameters  
array   array of strings, ints, or floats

intArray   array of ints

floatArray   array of floats

separator   String: a string to be placed between each item

digits   int: number of digits to pad with zeroes

left   int: number of digits to the left of the decimal point

right   int: number of digits to the right of the decimal point

   
Returns   String
   
Usage   Web & Application
   
Related   splitInts()
splitFloats()
splitStrings()
   
© 2004 - 2001 Massachusetts Institute of Technology and Interaction Design Institute Ivrea
Processing is an open project initiated by Ben Fry and Casey Reas