Results 1 to 2 of 2
Thread: Scanner class in my for loop
- 12-20-2010, 08:20 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 1
- Rep Power
- 0
Scanner class in my for loop
Alright I'm relatively new to Java and I'm nearly done with my first Java class.
I am currently working on my final and I have run into a snag. I probably knew the answer to this issue at one point, but have forgotten it.
Can someone explain to me why this code won't loop despite me sending the for loop the proper keyboard input via Scanner p so that the boolean would be true. I decided to make a small sample program so that no one will have to read through the pile of coding since my final is nearly complete I just need to loop it.
I would really appreciate fast help because my final and it is due in 20 minutes.
int j;
String i = "y";
for(j = 0; i == "y"; j++)
{
Scanner p = new Scanner(System.in);
System.out.println("y/n?");
i = p.nextLine();
}
- 12-20-2010, 10:48 AM #2
Similar Threads
-
Scanner, while loop and sorting arrays/string?
By RSYR in forum New To JavaReplies: 10Last Post: 04-20-2011, 07:13 PM -
Scanner Loop
By Phenomena in forum New To JavaReplies: 2Last Post: 04-01-2010, 07:47 PM -
Problem with while loop and the scanner method
By hhh80p in forum New To JavaReplies: 2Last Post: 02-28-2010, 12:47 PM -
Problem with scanner in loop
By grifan526 in forum New To JavaReplies: 2Last Post: 07-21-2009, 01:06 AM -
Scanner-While Loop
By hyunski in forum New To JavaReplies: 2Last Post: 03-12-2009, 03:15 AM
Bookmarks