+ 1

Error

Although I have used the import statement here, It says "The method Scanner(InputStream) is undefined for the type student" How can I resolve it? Code: import java.util.Scanner; class student { String usn; Scanner scan=new Scanner(System.in); // error here void read() { System.out.println("enter usn"); usn=scan.nextLine(); .........

31st May 2018, 2:07 PM
Rachita Nayak
Rachita Nayak - avatar
1 Réponse
+ 1
Hi Rachita Nayak , it seems that you forget main method. I cleaned your code. Please Try this- import java.util.Scanner; class student { public static void main(String args[]){ String usn; Scanner scan=new Scanner(System.in); System.out.println("enter usn"); usn=scan.nextLine(); System.out.println(usn); } }
31st May 2018, 2:28 PM
Sachin Artani
Sachin Artani - avatar
Aujourd'hui en vedette
.
1 Votes
What?
0 Votes
HTML
0 Votes
Web
0 Votes
Quiz duel
0 Votes
FRC Coding?
1 Votes
help
0 Votes
AI
2 Votes
APIs
1 Votes