fork download
  1. import java.lang.Math; // headers MUST be above the first class
  2. import java.util.concurrent.atomic.AtomicReference;
  3.  
  4. // one class needs to have a main() method
  5. public class HelloWorld
  6. {
  7. // arguments are passed using the text field below this editor
  8. public static void main(String[] args)
  9. {
  10. OtherClass myObject = new OtherClass("Hello World!");
  11. }
  12. }
  13.  
  14. // you can add other public classes to this editor in any order
  15. public class OtherClass
  16. {
  17. private AtomicReference<String> message;
  18. private boolean answer = false;
  19. public OtherClass(String input)
  20. {
  21. message = new AtomicReference<String>();
  22. message.set("Why, " + input + " Isn't this something?");
  23.  
  24. new java.util.Timer().schedule(
  25. new java.util.TimerTask() {
  26. @Override
  27. public void run() {
  28. // your code here
  29. System.out.print(message.get());
  30. }
  31. },
  32. 200);
  33. }
  34. public String toString()
  35. {
  36. return message.get();
  37. }
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:5: error: class HelloWorld is public, should be declared in a file named HelloWorld.java
public class HelloWorld
       ^
Main.java:15: error: class OtherClass is public, should be declared in a file named OtherClass.java
public class OtherClass
       ^
2 errors
stdout
Standard output is empty