This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes String arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String arrays" Watch "String arrays" New topic
Author

String arrays

scott morrison
Greenhorn

Joined: Dec 04, 2008
Posts: 1
need help with this bigtime, im trying to make a string array that will prompt the user for 5 names but i just cant get it working:
Any help is much appreciated

String[] Names;
Names = new String[5];

for (int i=0; i<5; i=i+1);
{
Names[i] = GUI.getString("enter names");
i = i + 1;
}
Leslie Viviani
Greenhorn

Joined: Jun 18, 2008
Posts: 4
One of the most obvious problems I see is that you are incrementing your counter twice. The following is a more common format for checking the length of the array as well:

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: String arrays
 
Similar Threads
Loops
String is in String array or not ?
Need Help for an Array.
EL question from Jdiscuss
NullPointerException