The following member variables can be defined in an abstract class:
Public abstract class People {public String name;public int age;public abstract void work ();}
In the people interface below, define the member variable error:
the meaning of the interface is understood : the interface can be understood as a unified "protocol", and the interface attribute is also the content of the protocol, but the interface properties are public, static, the final
member features of the interface :
A: Member variables can only be constants. Default modifier public static final
B: The member method can only be an abstract method. Default modifier public abstract
Recommended: Always manually give the modifier.
So the interface definition properties can be written like this:
public interface People {int age=10; String name= "Output name"; //The member variables defined inside the interface are public static final modifier public void eat (); Note: To give the initial value }
Defining member variables in the Java interface