Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Which method is more efficient?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Samuel A.
Which method is more efficient?
1 Answer(s)      4 years and 2 months ago
Posted in : Java Beginners


I'm faced with initializing a bunch of text fields in java. The problem is that the number of text fields is quite large, so i thought of putting them into an array and using a loop to initialize them. I want to know if this is better than using several lines to initialize all the text fields.

Samuel A. elimence@gmail.com


Advertisement
View Answers

October 18, 2010 at 9:34 PM


Hi,

May be you can initialize an array using following code:

//initialization String Arrays
String arr[] = {"Zero", "One", "Three"};
for (int i = 0; i < arr.length; i++) {
    String s = (String) arr[i];
    //Then use it
}

and the use in for(..) loop.

Thanks



Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com