aspose file tools*
The moose likes Java Micro Edition and the fly likes Loading a string array into J2ME List Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Loading a string array into J2ME List Class " Watch "Loading a string array into J2ME List Class " New topic
Author

Loading a string array into J2ME List Class

Ciaran Duffy
Greenhorn

Joined: Oct 25, 2003
Posts: 5
Hi - need some urgent help.
Trying to use List to display the output of a string array on screen as an IMPLICIT list.
If I declare exactly what strings are to be in the listArray when I declare it I can use the method without any trouble and it works fine.
list = new List("Staff: ", List.IMPLICIT, listArray, null);
However, I want to load the up the String array listArray with other strings in a for loop:
for(int i = 1; i <5; i++)
{
listArray[i] = inputString;
}
When I try this my program stalls - am i messing up with how I'm loading the string or is there another problem? Will List accept a string array this is compiled in this way?
Am programming for Palm BTW.
Cheers!
a sanjuan
Ranch Hand

Joined: Jun 12, 2002
Posts: 164
make sure when you go over the array you created that you don't go out of bounds. e.g.
String[] stringArray2=new String [5];
String inputString="hello";

for(int i = 0; i <5; i++)
{
stringArray2[i] = inputString;
}
the above should run fine and populate the list with the inputString. notice i start with i=0, which helps to make sure i don't get an index array out of bounds exception.
 
wood burning stoves
 
subject: Loading a string array into J2ME List Class