fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8.  
  9. class Main
  10. {
  11. public static void main(String args[])
  12. {
  13. Scanner sc =new Scanner(System.in);
  14.  
  15. for(;;)//This loop will always run till we break it from inside the loop
  16. {
  17. int ip=sc.nextInt(); //Taking input as an integer
  18. if(ip == 42) //If input is 42 , break the loop
  19. break;
  20. System.out.println(ip); //else print that integer and continue the loop
  21. }
  22. }
  23. }
Success #stdin #stdout 0.06s 4386816KB
stdin
4
65
42
48
stdout
4
65