day10--接口的常量的定义和使用
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.inmind.interface_constant05;
|
||||
/*
|
||||
接口中定义"成员属性",其实是一个常量,编译器会在成员属性前,默认加上【public static final】!!!
|
||||
final:最终,被它修饰的内容就不能更改
|
||||
接口中的常量的作用:为接口的行为规范,提供配套的固定值
|
||||
接口中的常量如何使用:接口名.常量名来调用
|
||||
*/
|
||||
public interface MyInterface {
|
||||
int a = 10;
|
||||
public static final String name = "张三";
|
||||
}
|
||||
Reference in New Issue
Block a user