Section E.8. Declaring and Initializing Variables

   

E.8 Declaring and Initializing Variables

E.8.1 Primitives

 boolean isAuthorized = true;  char size = 'm'; int age = 30; long ProductID = 01928493; 

E.8.2 Arrays

Arrays can be created and populated as shown below. Remember that Cold-Fusion arrays starts at 1; Java arrays start at 0.

In this example, an array of length 3 that will hold int s is declared. The first two cells are then populated with the values 1 and 2, respectively.

 int[] numbers = new int[3];  numbers[0] = 1; numbers[1] = 2; 

In this example, an int array is created and populated at the same time.

 int[] numbers = {1,2,3}; 

Arrays can also be populated in loops .

E.8.3 Objects

 String name;  String name = ''Zoe''; String name = new String(); Button saveButton = new Button(''save''); 

   
Top


Java for ColdFusion Developers
Java for ColdFusion Developers
ISBN: 0130461806
EAN: 2147483647
Year: 2005
Pages: 206
Authors: Eben Hewitt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net