public interface A {
 default void foo(){
 System.out.println("Calling A.foo()");
 }
 }
 
 public class Clazz implements A {
 }
 class c
 {
 public static void main(String[]args)
 {Clazz clazz = new Clazz();
 clazz.foo(); // Calling A.foo()
 }
 }
the code was used to understand default methods in interfaces of java,the code was not compiled,command prompt showed the following output:
c.java:2: error: illegal start of type
 default void foo(){
 ^
c.java:2: error: = expected
 default void foo(){
 ^
c.java:2: error: ';' expected
 default void foo(){
 ^
c.java:2: error: illegal start of type
 default void foo(){
 ^
c.java:2: error: <identifier> expected
 default void foo(){
 ^
c.java:2: error: = expected
 default void foo(){
 ^
c.java:2: error: ';' expected
 default void foo(){
 ^
c.java:3: error: illegal start of type
 System.out.println("Calling A.foo()");
 ^
c.java:3: error: = expected
 System.out.println("Calling A.foo()");
 ^
c.java:3: error: <identifier> expected
 System.out.println("Calling A.foo()");
 ^
c.java:3: error: illegal start of type
 System.out.println("Calling A.foo()");
 ^
c.java:5: error: class, interface, or enum expected
}
please help find the reason,thank you!