+ 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); } }

22nd Dec 2021, 8:05 AM
SH SHOUROV
SH SHOUROV - avatar
2 Respuestas
+ 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
22nd Dec 2021, 8:10 AM
Ipang
+ 2
Thanks I was using white spaces to give separate inputs. Thanks
22nd Dec 2021, 8:22 AM
SH SHOUROV
SH SHOUROV - avatar