Home > Back-end >  An anonymous inner class used in block of code
An anonymous inner class used in block of code

Time:05-04

Public class Animal {
Public void study () {};
}

The class Dog extends Animal {
}

The class Test {
Public static void main (String [] args) {
New Dog () {
{study (); }
};
}
}

In the Test class, study in the anonymous classes () why is {} wrapped up after not an error, do not add {} will be an error?

If a method has no method body {}, only (), that is not the interface methods in the form?
  • Related