fork download
  1. //package easy; // it should be hidden as compiler can't find the package called easy.
  2. import java.util.Scanner;
  3.  
  4. class Life_universeandEverything //it shouldn't be public as mentioned by @betlista
  5. {
  6. public static void main(String args[])
  7. {
  8. //System.out.println("Enter a number"); // hide it as it doesn't follow o/p format.
  9. //int a[]=new int[1000];//you don't know number of tests, better don't take an array.
  10. int n;
  11. Scanner s=new Scanner(System.in);
  12. while((n=s.nextInt())!=42)
  13. System.out.println(n); // o/p until you don't encounter integer 42.
  14. }
  15. }
Success #stdin #stdout 0.09s 380672KB
stdin
3
4
5
42
stdout
3
4
5