Scanner error in Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Scanner error in Java

In my code, it keeps giving me an error like. "/Playground/Program.java:2: error: '{' expected public class Program" But all I did was just import a Scanner What am I doing wrong for this to happen? public class Program import java.util.Scanner; { public static void main(String[] args) { Scanner owo = new Scanner(System.in); System.out.println("Do you think coding is hard?"); String input = owo.nextLine(); } }

10th Sep 2021, 1:35 PM
Err3c
Err3c - avatar
1 Answer
+ 3
Err3c import should be at top not inside class and at bottom.
10th Sep 2021, 1:37 PM
A͢J
A͢J - avatar