fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4.  
  5. /* The class name doesn't have to be Main, as long as the class is not public. */
  6. class Main
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. Scanner sc = new Scanner(System.in);
  11. String s;
  12. while (!(s=sc.next()).startsWith("42")) System.out.println(s);
  13. }
  14. }
Success #stdin #stdout 0.04s 246144KB
stdin
1
2
10
42
11
stdout
1
2
10