+ 1
Whats wrong with the following code
// I have tried running this code but it shows error import java.util.Scanner; public class Program { public static void main(String[ ] args) { Scanner read = new Scanner(System.in); System.out.println("Enter your color: "); String color = read.nextLine(); System.out.println("Enter your code: "); int code = read.nextInt(); System.out.println(" Your favorite color is " + color + "And your wifi password: " + code); } }
2 Answers
+ 3
No error syntactically. Maybe you didn't give enough inputs for it to work.
If that's the case, just run this code to see how input works in SoloLearn
https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
+ 2
Thanks I was using white spaces to give separate inputs. Thanks