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. private class Num {
  9. private int number1 = 10;
  10.  
  11. public void Num() {
  12. number1 = 100;
  13. }
  14.  
  15. public void disp() {
  16. System.out.println(number1);
  17. }
  18. }
  19. public class TestP {
  20. public static void main(String[] args) {
  21. Num n = new Num();
  22. n.disp();
  23. }
  24. }
  25.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:8: error: modifier private not allowed here
private class Num {
        ^
Main.java:19: error: class TestP is public, should be declared in a file named TestP.java
public class TestP {
       ^
2 errors
stdout
Standard output is empty