0
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 ?

Community
  • 1
  • 1
eemrah
  • 1,603
  • 3
  • 19
  • 37

1 Answers1

2

You probably want

while (getExp.hasNext()) {
    expression = getExp.next().charAt(0);
    ...
}
Reimeus
  • 158,255
  • 15
  • 216
  • 276