what's wrong in the following code and why static method inside the class inner throwing an exception?

class Sample{ public static void main(String args[]){ A.a(); } } class A{ static void a(){ class inner{ static void in(){ System.out.println(" im inner "); } } new inner().in(); } }

9/15/2019 2:25:31 PM


2 Answers

New Answer


An inner class can't have static methods. https://www.quora.com/Why-can’t-inner-class-methods-be-static-in-Java Remove static of your method void in() then it works.