08 2013 档案
摘要:在java中对list进行操作很频繁,特别是进行list遍历,这些操作我们都会,也很熟悉,但是对java中list进行删除元素,remove list中的元素就不怎么熟悉了吧,可以说很陌生,是实际操作中也很容易出错,先看看下面这个java中如何remove list 中的元素吧.publicclasstest {publicstaticvoidmain(String[] args) {String str1 =newString("abcde");String str2 =newString("abcde");String str3 =newString
阅读全文
摘要://Collections.sort(List list) 调用系统Comparable中的compareTo方法进行升序排序//Collections.sort(List list,Comparator) 根据指定比较器排序importjava.util.ArrayList;importjava.util.Collections;importjava.util.Comparator;importjava.util.List;publicclassSortTest{publicstaticvoidmain(String[]args){Listlists=newArrayList();Listl
阅读全文
摘要:java中的IO整理【案例1】创建一个新文件?1234567891011importjava.io.*;classhello{publicstaticvoidmain(String[] args) {File f=newFile("D:\\hello.txt");try{f.createNewFile();}catch(Exception e) {e.printStackTrace();}}}【运行结果】:程序运行之后,在d盘下会有一个名字为hello.txt的文件。【案例2】File类的两个常量?1234567importjava.io.*;classhello{publ
阅读全文
摘要:HashSet和TreeSet区别import java.util.HashSet;import java.util.Iterator;import java.util.TreeSet;public class SetTest {/*** @param args*/public static void main(String[] args) { // TODO 自动生成方法存根 HashSet ht = new HashSet(); ht.add("A"); ht.add("D"); ht.add("C"); ht.add("
阅读全文
摘要:Java中super的几种用法并与this的区别收藏1.子类的构造函数如果要引用super的话,必须把super放在函数的首位.classBase{Base(){System.out.println("Base");}}publicclassChecketextendsBase{Checket(){super();//调用父类的构造方法,一定要放在方法的首个语句System.out.println("Checket");}publicstaticvoidmain(Stringargv[]){Checketc=newChecket();}}如果想用supe
阅读全文
浙公网安备 33010602011771号