fork download
  1. /* package whatever; // don't place package name! */
  2. import java.util.Scanner;
  3.  
  4. /* The class name doesn't have to be Main, as long as the class is not public. */
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. //Create special object t got numerical input from a user...
  10. Scanner numberInputReader = new Scanner(System.in);
  11.  
  12. // Declare variable...
  13. int num1;
  14.  
  15. // Got a value from the user and put it into the variable...
  16. num1 = numberInputReader.nextInt();
  17.  
  18. // Use the variable by printing its contents...
  19. System.out.println( "my number is " + num1) ;
  20. }
  21. }
Success #stdin #stdout 0.05s 246144KB
stdin
7
stdout
my number is 7