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

 
 


Samuel A.
Which method is more efficient?
1 Answer(s)      2 years and 7 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

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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.