欢迎来到天天文库
浏览记录
ID:36885962
大小:212.00 KB
页数:19页
时间:2019-05-10
《JavaSE6新功能简介》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第21章JavaSE6新功能简介JavaSE6基本新功能ApacheDerby、JDBC4.0java.lang套件在JavaSE6中,String类别上新增了isEmpty()方法Stringstr="";if(str.isEmpty()){…}java.util套件在JavaSE6中,Arrays类别新增了copyOf()方法int[]arr1={1,2,3,4,5};int[]arr2=Arrays.copyOf(arr1,arr1.length);for(inti=0;i2、stem.out.println();int[]arr1={1,2,3,4,5};int[]arr2=Arrays.copyOf(arr1,10);for(inti=0;i3、intresult=Arrays.binarySearch(arr1,6,9,85);if(result>-1){System.out.printf("索引%d处找到数据%n",result);}else{System.out.printf("插入点%d%n",(result+1)*-1);}java.util套件在JavaSE6中,您可以直接使用getDisplayNames()或getDisplayName()方法取得区域化的日期格式显示CalendarrightNow=Calendar.getInstance();Localelocale=Locale.getDefa4、ult();System.out.println("现在时间是:");System.out.printf("%s:%d%n",rightNow.getDisplayName(ERA,LONG,locale),rightNow.get(YEAR));System.out.println(rightNow.getDisplayName(MONTH,LONG,locale));System.out.printf("%d日%n",rightNow.get(DAY_OF_MONTH));System.out.println(rightNow.getDisplayName(DAY_OF5、_WEEK,LONG,locale));java.io套件使用System类别上新增的console()方法使用Console物件的readLine()方法System.out.print("输入名称:");Stringname=System.console().readLine();System.out.print("输入密码:");char[]passwd=System.console().readPassword();Stringpassword=newString(passwd);if("caterpillar".equals(name)&&"123456".equ6、als(password)){System.out.println("欢迎caterpillar");break;}else{System.out.printf("%s,名称或密码错误,请重新输入!%n",name);}java.io套件Stringname=console.readLine("[%s]","输入名称…");char[]passwd=console.readPassword("[%s]","输入密码…");Stringpassword=newString(passwd);if("caterpillar".equals(name)&&"123456".equa7、ls(password)){System.out.println("欢迎caterpillar");break;}else{System.out.printf("%s,名称或密码错误,请重新输入!%n",name);}java.io套件在JavaSE6中,对于File类别新增了几个方法File[]roots=File.listRoots();for(Fileroot:roots){System.out.printf("%s总容量%d,可用容量%d%n",root.getPath(),root.getTotalSpa
2、stem.out.println();int[]arr1={1,2,3,4,5};int[]arr2=Arrays.copyOf(arr1,10);for(inti=0;i3、intresult=Arrays.binarySearch(arr1,6,9,85);if(result>-1){System.out.printf("索引%d处找到数据%n",result);}else{System.out.printf("插入点%d%n",(result+1)*-1);}java.util套件在JavaSE6中,您可以直接使用getDisplayNames()或getDisplayName()方法取得区域化的日期格式显示CalendarrightNow=Calendar.getInstance();Localelocale=Locale.getDefa4、ult();System.out.println("现在时间是:");System.out.printf("%s:%d%n",rightNow.getDisplayName(ERA,LONG,locale),rightNow.get(YEAR));System.out.println(rightNow.getDisplayName(MONTH,LONG,locale));System.out.printf("%d日%n",rightNow.get(DAY_OF_MONTH));System.out.println(rightNow.getDisplayName(DAY_OF5、_WEEK,LONG,locale));java.io套件使用System类别上新增的console()方法使用Console物件的readLine()方法System.out.print("输入名称:");Stringname=System.console().readLine();System.out.print("输入密码:");char[]passwd=System.console().readPassword();Stringpassword=newString(passwd);if("caterpillar".equals(name)&&"123456".equ6、als(password)){System.out.println("欢迎caterpillar");break;}else{System.out.printf("%s,名称或密码错误,请重新输入!%n",name);}java.io套件Stringname=console.readLine("[%s]","输入名称…");char[]passwd=console.readPassword("[%s]","输入密码…");Stringpassword=newString(passwd);if("caterpillar".equals(name)&&"123456".equa7、ls(password)){System.out.println("欢迎caterpillar");break;}else{System.out.printf("%s,名称或密码错误,请重新输入!%n",name);}java.io套件在JavaSE6中,对于File类别新增了几个方法File[]roots=File.listRoots();for(Fileroot:roots){System.out.printf("%s总容量%d,可用容量%d%n",root.getPath(),root.getTotalSpa
3、intresult=Arrays.binarySearch(arr1,6,9,85);if(result>-1){System.out.printf("索引%d处找到数据%n",result);}else{System.out.printf("插入点%d%n",(result+1)*-1);}java.util套件在JavaSE6中,您可以直接使用getDisplayNames()或getDisplayName()方法取得区域化的日期格式显示CalendarrightNow=Calendar.getInstance();Localelocale=Locale.getDefa
4、ult();System.out.println("现在时间是:");System.out.printf("%s:%d%n",rightNow.getDisplayName(ERA,LONG,locale),rightNow.get(YEAR));System.out.println(rightNow.getDisplayName(MONTH,LONG,locale));System.out.printf("%d日%n",rightNow.get(DAY_OF_MONTH));System.out.println(rightNow.getDisplayName(DAY_OF
5、_WEEK,LONG,locale));java.io套件使用System类别上新增的console()方法使用Console物件的readLine()方法System.out.print("输入名称:");Stringname=System.console().readLine();System.out.print("输入密码:");char[]passwd=System.console().readPassword();Stringpassword=newString(passwd);if("caterpillar".equals(name)&&"123456".equ
6、als(password)){System.out.println("欢迎caterpillar");break;}else{System.out.printf("%s,名称或密码错误,请重新输入!%n",name);}java.io套件Stringname=console.readLine("[%s]","输入名称…");char[]passwd=console.readPassword("[%s]","输入密码…");Stringpassword=newString(passwd);if("caterpillar".equals(name)&&"123456".equa
7、ls(password)){System.out.println("欢迎caterpillar");break;}else{System.out.printf("%s,名称或密码错误,请重新输入!%n",name);}java.io套件在JavaSE6中,对于File类别新增了几个方法File[]roots=File.listRoots();for(Fileroot:roots){System.out.printf("%s总容量%d,可用容量%d%n",root.getPath(),root.getTotalSpa
此文档下载收益归作者所有