I want to read input from a console for example
Enter input:
aabbbab
execute the method when pressed Enter
and keep asking for input and execute till a character is typed in.
At the moment I can read an input and enter it execute it.Then I need to run a program again to enter a new input.
-
It is always a good idea to post sample code along with your questions if applicable, as it helps others diagnose more effectively.akf– akf2009-09-03 22:31:06 +00:00Commented Sep 3, 2009 at 22:31
Add a comment
|
3 Answers
I think what you are asking for is to do something (in this case taking input and working on it) repeatedly. It should be clear that when you want to do the same thing repeatedly, you should put that code inside a loop. What that loop looks like (e.g. for, do, while etc.) and what its exit condition is, is up to you.
Comments
We can read string from console application using console class
String username = console.readLine("Enter username: ");
System.out.println(username);
1 Comment
Andrew Barber
Your answer adds nothing to this question than what has already been said - except the link to your blog.