I was reading Programming with java for Dummies 2nd Edition and came across this piece of code. I tried to read a chrachter using scannerobj.findInLine(".").charAt(0) method.
But I get an exception saying theres no such method. And even nextLine, nextWord isnt working.
Please help.
I have pasted the exact code from that book.
import java.util.Scanner;
import java.util.Scanner;
class ReverseWord {
public static void main(String args[]) {
Scanner myScanner = new Scanner(System. in );
char c1, c2, c3, c4;
c1 = myScanner.findInLine(".").charAt(0);
c2 = myScanner.findInLine(".").charAt(0);
c3 = myScanner.findInLine(".").charAt(0);
c4 = myScanner.findInLine(".").charAt(0);
System.out.print(c4);
System.out.print(c3);
System.out.print(c2);
System.out.print(c1);
System.out.println();
}
}
This is the exception that I got.
E:\JAVA Programs\chartest>java MyClass
Exception in thread "main" java.lang.NoSuchMethodError: main