当前位置: 首页 > news >正文

个人可以备案几个网站网站建设群发广告词

个人可以备案几个网站,网站建设群发广告词,互联网广告投放公司,百度 站长工具jdk1.7新特性详解 开发期间略知jdk1.7的一些特性#xff0c;没有真正的一个一个得展开研究#xff0c;而是需要说明再去查#xff0c;导致最整个新特性不是特别的清楚#xff0c;这种情况以后得需要改变了#xff0c;否则就会变成代码的奴隶。现在正好有时间可以细细的研…jdk1.7新特性详解 开发期间略知jdk1.7的一些特性没有真正的一个一个得展开研究而是需要说明再去查导致最整个新特性不是特别的清楚这种情况以后得需要改变了否则就会变成代码的奴隶。现在正好有时间可以细细的研究研究了。文章主要参照oracle jdk1.7的官方地址https://docs.oracle.com/javase/7/docs/technotes/guides/language/enhancements.html#javase7 jdk17新特性详解 二进制字面量在数字字面量使用下划线switch可以使用string了实例创建的类型推断使用Varargs方法使用不可维护的形式参数时改进了编译器警告和错误try-with-resources 资源的自动管理捕捉多个异常类型和对重新抛出异常的高级类型检查 try-with-resources 资源的自动管理 try-with-resources 声明是try 一个或多个资源的声明。一个资源作为一个对象在程序结束之后必须关闭它。try-with-resources声明保证每一个资源都会被关闭在声明结束的时候。任何实现了java.lang.AutoCloseable接口或者实现了java.io.Closeable可以作为一个资源。 下面的例子从文件中读取第一行。用到了BufferedReader得实例去从文件中读取数据。BufferedReader是一个资源在程序完成之后必须关闭。 static String readFirstLineFromFile(String path) throws IOException {try (BufferedReader br new BufferedReader(new FileReader(path))) {return br.readLine();} }在这个例子中在try-with-resources语句中声明的资源是BufferedReader。声明语句出现在try关键字后面的括号内。BufferedReaderJava SE 7及更高版本中的类实现了接口java.lang.AutoCloseable。由于BufferedReader实例是在try-with-resource语句中声明的因此无论try语句是正常还是意外完成由于方法BufferedReader.readLine抛出IOException它都将被关闭。 在Java SE 7之前无论try语句是正常还是意外完成都可以使用finally块来确保资源已关闭。以下示例使用finally代替try-with-resources语句的块 static String readFirstLineFromFileWithFinallyBlock(String path) throws IOException {BufferedReader br new BufferedReader(new FileReader(path));try {return br.readLine();} finally {if (br ! null) br.close();} }然而在这个例子中如果方法readLine和close都抛出异常方法readFirstLineFromFileWithFinallyBlock则抛出由finally块抛出的异常由try块排除的异常将会被抑制。相反在例子readFirstLineFromFile中如果try块和try-with-resources声明都抛出异常方法readFirstLineFromFile则抛出由try块抛出的异常由try-with-resources抛出的异常将会被抑制。 您可以在try-with-resources语句中声明一个或多个资源。以下示例将检索打包在zip文件zipFileName中的文件的名称并创建一个包含这些文件名称的文本文件 public static void writeToFileZipFileContents(String zipFileName, String outputFileName)throws java.io.IOException {java.nio.charset.Charset charset java.nio.charset.Charset.forName(US-ASCII);java.nio.file.Path outputFilePath java.nio.file.Paths.get(outputFileName);// Open zip file and create output file with try-with-resources statementtry (java.util.zip.ZipFile zf new java.util.zip.ZipFile(zipFileName);java.io.BufferedWriter writer java.nio.file.Files.newBufferedWriter(outputFilePath, charset)) {// Enumerate each entryfor (java.util.Enumeration entries zf.entries(); entries.hasMoreElements();) {// Get the entry name and write it to the output fileString newLine System.getProperty(line.separator);String zipEntryName ((java.util.zip.ZipEntry)entries.nextElement()).getName() newLine;writer.write(zipEntryName, 0, zipEntryName.length());}}}在此示例中try-with-resources语句包含两个用分号分隔的声明ZipFile和BufferedWrite。当直接跟随它的代码块正常结束或由于异常而终止时close这些BufferedWriter和ZipFile对象的方法将按此顺序自动调用。请注意close资源的方法是按照与创建相反的顺序来调用的。 捕捉多个异常类型和对重新抛出异常的高级类型检查 处理大于一种类型的异常 在JAVA SE 7 以及以后的版本中一个简单的catch块可以处理大于一种类型的异常。这个功能可以减少代码重复并且减少了对捕获广泛异常的诱惑。 注意下面的例子每一个catch块都包含重复代码 catch (IOException ex) {logger.log(ex);throw ex; catch (SQLException ex) {logger.log(ex);throw ex; }在Java SE 7以前的版本中创建一个通用的方法来消除重复的代码是很困难的因为变量ex有不同的类型。 以下示例在Java SE 7及更高版本中有效可消除重复的代码 catch (IOException|SQLException ex) {logger.log(ex);throw ex; }该catch子句指定类型的块处理异常的以及每个异常类型与竖线分割|。 注意如果一个catch块处理多个异常类型则该catch参数是隐式的final。在这个例子中这个catch参数ex是final所以你不能在这个catch块中赋值。 一个catch块处理多个异常编译生成的字节码要比多个catch块且每个只处理一个异常生成的字节码要小的多并且优化。一个catch块处理多个异常的代码块通过编译器生成的字节码代码不重复字节码没有对异常处理程序的复制。 JDK8 1、Lambda 演变过程 2、StreamAPI 详解 3、Date StreamAPI 详解 功能 父类BasicStream 子类Stream、IntStream、LongStream、DoubleStream 包含两个类型中间操作 (intermediate operations) 和结束操作 (terminal operations) 下面是所有方法的属于那一端操作的方法 //1.将集合转换成流list.stream();//2.forEach 遍历list.forEach(System.out::println);//3.filter过滤list.stream().filter((e) - e.getStar().equals(天秤座)).forEach(System.out::println);OptionalStudent optionalStudent list.stream().filter((e) - e.getStar().equals(天秤座)).findAny();Student student optionalStudent.get();//4.map 转换集合ListString names list.stream().map(Student::getName).collect(Collectors.toList());names.stream().forEach(System.out::println);MapString, Object map new HashMap();map.put(key1,1);map.put(key2,1);map.put(key3,1);map.put(key4,1);ListString cidList map.keySet().stream().map(String::toString).collect(Collectors.toList()); System.out.println(cidList);//5.mapToInt 转换数值流IntStream intStream list.stream().mapToInt(Student::getAge);StreamInteger integerStream intStream.boxed();OptionalInteger max integerStream.max(Integer::compareTo);System.out.println(max.get());//6.flatMap 合并成一个流ListString list2 new ArrayList();list2.add(aaa bbb ccc);list2.add(ddd eee fff);list2.add(ggg hhh iii);list2.add(ggg hhh iii);list2 list2.stream().map(s - s.split( )).flatMap(Arrays::stream).collect(Collectors.toList());System.out.println(list2);//7.distinct 去重list2.stream().distinct().forEach(System.out::println)//复杂去重 // ListRedPacketRecord newList records.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() - new TreeSet(Comparator.comparing(RedPacketRecord::getRoomId))), ArrayList::new));//8、sorted 排序//asc排序list.stream().sorted(Comparator.comparingInt(Student::getAge)).forEach(System.out::println);System.out.println(------------------------------------------------------------------);//desc排序list.stream().sorted(Comparator.comparingInt(Student::getAge).reversed()).forEach(System.out::println);//9、skip 跳过前 n 个list.stream().skip(1).forEach(System.out::println);//10、limit 截取前 n 个list.stream().limit(1).forEach(System.out::println);//11、anyMatchboolean isHave list.stream().anyMatch(student2 - student2.getAge() 16);System.out.println(isHave);//12、allMatchboolean isHave2 list.stream().allMatch(student2 - student2.getAge() 16);System.out.println(isHave2);//13、noneMatchboolean isHave3 list.stream().noneMatch(student2 - student2.getAge() 16);System.out.println(isHave3);//14、findAnyOptionalStudent student list.stream().findAny();System.out.println(student.get());//15、findFirstOptionalStudent student list.stream().findFirst();System.out.println(student.get());//17、count 计数long count list.stream().count();System.out.println(count);//18、ofStreamString stringStream Stream.of(i,love,you);//19、emptyStreamString stringStream2 Stream.empty();//20、iterateListString list Arrays.asList(a, b, c, c, d, f, a);Stream.iterate(0, i - i 1).limit(list.size()).forEach(i - {System.out.println(String.valueOf(i) list.get(i));});//21、collectaveragingLong// 求年龄平均值CollectorStudent, ?, Double studentDoubleCollector Collectors.averagingLong(Student::getAge);Double average list.stream().collect(studentDoubleCollector);//22、collectcollectingAndThen// 求年龄平均值String average2 list.stream().collect(Collectors.collectingAndThen(Collectors.averagingInt(Student::getAge), a-哈哈平均年龄a));System.out.println(average2);//23、collectcounting// 求数量Long num list.stream().collect(Collectors.counting());System.out.println(num);//24、collect: groupingBy(Function)MapInteger,ListStudent result list.stream().collect(Collectors.groupingBy(Student::getAge));for (Integer age:result.keySet()){System.out.println(result.get(age));}//25、collectgroupingBy(Function,Collector)// 先分组在计算每组的个数MapInteger,Long num list.stream().collect(Collectors.groupingBy(Student::getAge,Collectors.counting()));System.out.println(num);//26、collectgroupingBy(Function, Supplier, Collector)// 先分组在计算每组的个数,然后排序MapInteger,Long num list.stream().collect(Collectors.groupingBy(Student::getAge, TreeMap::new,Collectors.counting()));System.out.println(num);//27、collectgroupingByConcurrent // 同上不过这个 Concurrent 是并发的也有 3 个方法和上面非并发一个效果 // groupingByConcurrent(Function) // groupingByConcurrent(Function, Collector) // groupingByConcurrent(Function, Supplier, Collector)//28、collectjoining()// 名字拼接String result3 list.stream().map(Student::getName).collect(Collectors.joining());System.out.println(result3);//29、collectjoining(str)// 名字拼接,用逗号隔开String result4 list.stream().map(Student::getName).collect(Collectors.joining(,));System.out.println(result4);//30、collectjoining(str, prefix, suffix)// 名字拼接,包含前缀、后缀String result5 list.stream().map(Student::getName).collect(Collectors.joining(,,hello,world));System.out.println(result5);//31、collectsummarizingDouble// 求年龄的最大值、最小值、平均值、综合以及人数DoubleSummaryStatistics result6 list.stream().collect(Collectors.summarizingDouble(Student::getAge));System.out.println(result6);//32、collecttoCollectionimport lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString;/*** ClassName Student* Author: c-wangjz02* Description:*/ Data ToString NoArgsConstructor AllArgsConstructor public class Student {//名字private String name;//性别private String sex;//薪水private int salary;//年龄private int age;//星座private String star; }
http://www.w-s-a.com/news/51929/

相关文章:

  • 信誉最好的20个网投网站凡科网站建设之后怎么删除
  • 天津网站开发技术广州网站优化公司排名
  • 养老做增减的网站医院网站怎么做优化排名
  • 企业网站的推广方法有哪些上海猎头公司前十名
  • 电商网站建设建议免费下载app
  • 网站搭建设计是什么意思百度地图放到网站上
  • 东莞网站建设市场分析淘宝网站框架
  • 新网站多久被百度收录网站空间单位
  • 2017常用的网站昆明网站代理
  • 成都海鸥手表网站安阳网站建设策划
  • 做好的网站怎么发布做网站应该做哪方面的
  • 可以找厂家的网站品牌创意型网站开发
  • 有没有做牛羊角的网站电商网站报价
  • 网站建设行业咨讯文章网站兼容模式怎么设置
  • 商务网站建设概念东莞做网站的公司吗
  • 高稳定性的网站设计制作wordpress 检测插件
  • 无锡网站制作排名自适应网站建设推荐
  • 度娘网站桃花怎么做网站制作 p
  • 小欢喜林磊儿什么网站做家教搜索优化公司
  • 龙岗做网站哪里找网站建设简介是什么意思
  • 做网站的标准北京西站出站口
  • asp.net新建网站市场营销管理是做什么的
  • 南昌网站建设模板服务商建设什么网站挣钱
  • 网站建设实训记录企业网站建设运营
  • 视频网站文案住房和城乡建设部门
  • 汕头网站排名推广新余门户网站开发
  • 湖南智能网站建设哪家好wordpressμ
  • 公司网站备案必须是企业信息么睢宁县凌城做网站的
  • 上海网站建设公司 珍岛宁波免费自助建站模板
  • 南昌知名的网站建设公司南京网站开发选南京乐识赞