我是靠谱客的博主 顺利红酒,最近开发中收集的这篇文章主要介绍public类的static 属性 和 public interface接口的属性的比较1.外部类2.接口,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
前言
有些人不喜欢用枚举类,喜欢用普通公开类的静态最终属性,有些喜欢用公开接口的属性,现在说说区别
1.外部类
package com.dalaoyang.utils;
public class DbUtil {
/**数据库ds_master1**/
public static final String DB_MASTER1 = "ds_master1";
/**数据库ds_master2**/
public static final String DB_MASTER2 = "ds_master2";
}
2.接口
package com.dalaoyang.utils;
public interface DbUtilA {
/**数据库ds_master1**/
String DB_MASTER1 = "ds_master1";
/**数据库ds_master2**/
String DB_MASTER2 = "ds_master2";
}
比较:接口中所有的属性是隐式的static和final的,也就是说,DbUtil和DbUtilA是一样的。
最后
以上就是顺利红酒为你收集整理的public类的static 属性 和 public interface接口的属性的比较1.外部类2.接口的全部内容,希望文章能够帮你解决public类的static 属性 和 public interface接口的属性的比较1.外部类2.接口所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复