Reputation: 1
I have imported the java class but i keep getting this error with the following code
Error: C:\Users\xiangzheng\Desktop\passoff\P70.java:51: error: cannot find symbol String a = scanner.next;
Code:
Scanner scanner = new Scanner(sentence);
scanner.useDelimiter(" ");
String a = scanner.next;
Upvotes: 0
Views: 553
Reputation: 33
I believe next is a method, not a variable.
Try this and let me know if it works.
String a = scanner.next();
Upvotes: 2
Reputation: 133587
Probably you are just missing the parenthesis from the method invokation, try with
String a = scanner.next();
scanner.next tries to access to an instance variable which doesn't exist for Scanner
class.
Upvotes: 6