
Java
hjiam2
渴望成为一名码农,爱生活,爱运动,爱编程
展开
-
Java中接口里定义的成员变量
首先你要弄清接口的含义.接口就是提供一种统一的'协议’,而接口中的属性也属于'协议’中的成员.它们是公共的,静态的,最终的常量.相当于全局常量。 在interface里面的变量都是public static final 的。所以你可以这样写: public static final int i=10; 或则 int i=10;(可以省略掉一部分)原创 2014-07-26 17:49:38 · 1166 阅读 · 0 评论 -
两种方法删除ArrayList里重复元素
方法一: /** List order not maintained **/ public static void removeDuplicate(ArrayList arlList) { HashSet h = new HashSet(arlList); arlList.clear(); arlList.addAll(h); } 方法二: /** Lis原创 2014-07-10 19:58:56 · 957 阅读 · 0 评论 -
打印文件的最后K行(C++和Java实现)
如题,file.txt的内容如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 C++实现: #include #include #include using namespace std; //const unsigned int k = 5; #define k 5 void printLastKLines(ifstream &原创 2014-09-02 16:54:16 · 1374 阅读 · 1 评论