Why can't I write like this? what's wrong in this? We can extend JFrame and can write it like that then why is that not possible in this case?
import java.util.Scanner;
class mainClass extends Scanner {
private int number;
mainClass() {
super(System.in);
System.out.print("Enter your number");
number = nextInt();
System.out.println("This is your number "+number);
}
}