I'm don't know how to read from the console in Java. If it's possible I want to do it using a scanner. This is what i tried while learning Java.
package Scanners;
import java.util.Scanner;
public class ConsoleScanner {
static Scanner input = new Scanner(System.in);
public static void main(String[] args){
if(input.equals("Hello"))
System.out.println("You typed in: Hello ");
if(input.equals("Good Bye"))
System.out.println("You typed in: Good Bye");
else{
System.out.println("You typed in: " + input);
}
}
}
It give's me this error:
You typed in: java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false][group separator=.][decimal separator=\,][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q?\E][infinity string=\Q?\E]
If there is a better way to read from the console then please post it. - Thanks