tags:

views:

252

answers:

2

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.

+2  A: 

`

BufferedReader console = new BufferedReader (new InputStreamReader(System.in));

while(true){

    String text = console.readLine();
    doStuff(text)
}

`

Nettogrof
A: 

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.

MAK