Reputation: 1700
import java.util.Scanner;
public class myClass {
public static void main(String[] args)
{
String[] exampleString;
char expression;
Scanner getExp = new Scanner(System.in);
while(expression = getExp.next().charAt(0))
{
// myString will added by expression character
}
}
}
I tried it on Eclipse Mars but
expression = getExp.next().charAt(0) part gets error always.
I didn't understand that what is the error .
Previously i think on this link stackoverflow Scanner question
am i think wrong ?
Upvotes: 0
Views: 535
Reputation: 159794
You probably want
while (getExp.hasNext()) {
expression = getExp.next().charAt(0);
...
}
Upvotes: 2