Hey guys - this is officially my first post on this site, so I'm hoping it works out well for me. I am spanking new to Java, and am currently working on a homework assignment and I'm caught up on these loops and arrays. The question seems simple, I'm just not starting off too well. The second loop is what confuses me most. Here's the question:
Write a loop that reads 10 strings and inserts them into an array list. Write a second loop that prints out the strings in the opposite order from which they were entered.
Here's what I have so far. And be easy on me!
ArrayList <String> read = new ArrayList <String>();
String read = new String;
for (String i = 0; i < read, i++)
What in sam goodies am I doing wrong and where do I start with fixing this mess. LOL! Thanks so much everyone.
seetharaman venkatasamy wrote:Please DoYourOwnHomework . any way ,what do you think about "Stack"? . and welcome to javaranch
I think Victor Ewert's answer was at the correct level; he explained what is going wrong, and also corrected Kay Jay's interpretation of the question.
It says to use ArrayList, so you have to forget about Stacks.
But suresh senapathi's answer does not help. This, I think, has overstepped the mark between helping and doing somebody else's homework. Apart from some poor design features, giving answers like that does not help at all, so I shall feel obliged to "pull rank" and delete the answer.
Joined: Jan 14, 2009
may be Victor Ewert answer is correct.BUt in that he diplayed what ever the data exist in array list.but seetharaman venkatasamy asks data in reverse order from the list.
Q: Write a loop that reads 10 strings and inserts them into an array list. Write a second loop that prints out the strings in the opposite order from which they were entered. That's why i have give my understanding.i am not sure it is correct.