Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading a string array into J2ME List Class

 
Ciaran Duffy
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 164
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic