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. class Ideone
  9. {
  10. class Catty{
  11. int x =0;
  12. public void printX(){
  13. System.out.print(x);
  14. }
  15. }
  16. class Kitten extends Catty{
  17. int x = -1;
  18. @Override
  19. public void printX(){
  20. System.out.print(x);
  21. }
  22. }
  23. public class Cat {
  24. public static void main(String[] args) {
  25. Catty a=new Kitten();
  26. a.printX();
  27. }
  28. }
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:25: error: non-static variable this cannot be referenced from a static context
Catty a=new Kitten();
        ^
Main.java:24: error: Illegal static declaration in inner class Ideone.Cat
public static void main(String[] args) {
                   ^
  modifier 'static' is only allowed in constant variable declarations
2 errors
stdout
Standard output is empty