Running Java file’s code wouldn’t respond to user input, and didn’t output anything. it just continuously runs.
I don’t know if it’s how my vscode is setup or what, but when running the code below, it works fine when using the terminal, but doesn’t work at all when trying to run it through the output window by pressing ctrl + alt + n.
System.out.println("Enter the first Number: ");
int n1 = input.nextInt();
System.out.println("Enter the second Number: ");
int n2 = input.nextInt();
System.out.println("n1 = "+ n1 + "n2 = " +n2);
I tried messing around with the launch.json
file, but that didn’t do much. I have all the extensions installed that I felt like I needed in my vscode. I have the import statement for my scanner too. It’s in the public static void main block, so that’s covered.
I even tried deleting my project several times, and making new projects in my vscode, but that didn’t work either.
All my other Java files work perfectly fine, but for some reason, this one doesn’t. I looked up online, but couldn’t find much. Asking chatgpt didn’t help much either. I hope this question is understandable, since i’m not too sure on how to phrase it.
Jay is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1