0
Problem running code
I always get a null exception whenever I try run code which make use of the until.Scanner class. Example: public class Names public static void main (String[] args){ Scanner input = new Scanner(System.in); String name; System.out.println("Your name: "); name = input.next(); System.out.println(name); } The above code will throw an exception when I try to run it. Can someone help out, maybe I may not be seeing the error. Thank you.
2 Answers
+ 2
You should write java.util.Scanner not until
+ 1
not a necessity but should put input.close(); at the end as well...
and not sure if miss-print but you need a "{" after the public class...
public class Names{
...
}