The program compiles and runs, but it is not allowing me to input any value. The program just ends without letting me input anything. Why?
package prac;
import java.util.Scanner;
public class prac {
public static void main(String args[]) {
Scanner input = new Scanner(System. in );
int number;
System.out.println("Input number: ");
number = input.nextInt();
System.out.println(number);
}
}
I believe what's happening is (I may be wrong) it is executing all the code and then closing so fast that you couldnt possibly input anything.
If you want to give arguments on RunTime , right click on java file go to Run AS -> run configurations and you can pass arguments by clicking Arguments Tab ,using program variables option
Looks like you are missing a close statement for Scanner
try:
Your probably not getting focus on the console. AFter you run the java program switch to the console.