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

企业做网站的步骤与做网站注意事项/全网推广

企业做网站的步骤与做网站注意事项,全网推广,白云区网站建设,wordpress 百度地图插件在jdk7的新特性方面主要有一下几方面的增强 本文是我学习了解了jdk7和jdk8的一些新特性的一些资料,有兴趣的大家可以浏览下下面的内容。官方文档 在jdk7的新特性方面主要有下面几方面的增强:jdk1.7语法上 1.1 二进制变量的表示,支持将整数类型…

在jdk7的新特性方面主要有一下几方面的增强

本文是我学习了解了jdk7和jdk8的一些新特性的一些资料,有兴趣的大家可以浏览下下面的内容。官方文档

  • 在jdk7的新特性方面主要有下面几方面的增强:
  1. jdk1.7语法上

    1.1 二进制变量的表示,支持将整数类型用二进制来表示,以0b开头。

    所有整数int、short、long、byte都可以用二进制表示

    // An 8-bit 'byte' value:
    byte aByte = (byte) 0b00100001;
     ```

    // A 16-bit 'short' value:
    short aShort = (short) 0b1010000101000101;

    // Some 32-bit 'int' values:
    intanInt1 = 0b10100001010001011010000101000101;
    intanInt2 = 0b101;
    intanInt3 = 0B101; // The B can be upper or lower case.

    // A 64-bit 'long' value. Note the "L" suffix:
    long aLong = 0b1010000101000101101000010100010110100001010001011010000101000101L;

    // 二进制在数组等的使用
    final int[] phases = { 0b00110001, 0b01100010, 0b11000100, 0b10001001,
    0b00010011, 0b00100110, 0b01001100, 0b10011000 };

    
    1.2 Switch语句支持String类型
    

    public void String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) {
    String typeOfDay;
    switch (dayOfWeekArg) {
    case "Monday":
    typeOfDay = "Start of work week";
    break;
    case "Tuesday":
    case "Wednesday":
    case "Thursday":
    typeOfDay = "Midweek";
    break;
    case "Friday":
    typeOfDay = "End of work week";
    break;
    case "Saturday":
    case "Sunday":
    typeOfDay = "Weekend";
    break;
    default:
    throw new IllegalArgumentException("Invalid day of the week: " + dayOfWeekArg);
    }
    return typeOfDay;
    }
    ```

    1.3 Try-with-resource语句

    注意:实现java.long.AutoCloseable接口的资源都可以放到try中,
    跟final里面的关闭资源类似;按照声明逆序关闭资源;Try块抛出的异常Throwable.getSuppressed获取。

      try (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());}}```1.4 Catch多个异常 说明:Catch异常类型为final; 生成Bytecode 会比多个catch小; Rethrow时保持异常类型```public static void main(String[] args) throws Exception {try {testthrows();} catch (IOException | SQLException ex) {throw ex;}}public static void testthrows() throws IOException, SQLException {}```1.5 数字类型的下划线表示 更友好的表示方式,不过要注意下划线添加的一些标准,可以参考下面的示例```long creditCardNumber = 1234_5678_9012_3456L;long socialSecurityNumber = 999_99_9999L;float pi = 3.14_15F;long hexBytes = 0xFF_EC_DE_5E;long hexWords = 0xCAFE_BABE;long maxLong = 0x7fff_ffff_ffff_ffffL;byte nybbles = 0b0010_0101;long bytes = 0b11010010_01101001_10010100_10010010; //float pi1 = 3_.1415F;      // Invalid; cannot put underscores adjacent to a decimal point//float pi2 = 3._1415F;      // Invalid; cannot put underscores adjacent to a decimal point//long socialSecurityNumber1= 999_99_9999_L;         // Invalid; cannot put underscores prior to an L suffix //int x1 = _52;              // This is an identifier, not a numeric literalint x2 = 5_2;              // OK (decimal literal)//int x3 = 52_;              // Invalid; cannot put underscores at the end of a literalint x4 = 5_______2;        // OK (decimal literal) //int x5 = 0_x52;            // Invalid; cannot put underscores in the 0x radix prefix//int x6 = 0x_52;            // Invalid; cannot put underscores at the beginning of a numberint x7 = 0x5_2;            // OK (hexadecimal literal)//int x8 = 0x52_;            // Invalid; cannot put underscores at the end of a number int x9 = 0_52;             // OK (octal literal)int x10 = 05_2;            // OK (octal literal)//int x11 = 052_;            // Invalid; cannot put underscores at the end of a number ```1.6 泛型实例的创建可以通过类型推断来简化 可以去掉后面new部分的泛型类型,只用<>就可以了。```List strList = new ArrayList(); List<String> strList4 = new ArrayList<String>(); List<Map<String, List<String>>> strList5 =  new ArrayList<Map<String, List<String>>>();``````//编译器使用尖括号 (<>) 推断类型 List<String> strList0 = new ArrayList<String>(); List<Map<String, List<String>>> strList1 =  new ArrayList<Map<String, List<String>>>(); List<String> strList2 = new ArrayList<>(); List<Map<String, List<String>>> strList3 = new ArrayList<>();List<String> list = new ArrayList<>();list.add("A");// The following statement should fail since addAll expects// Collection<? extends String>//list.addAll(new ArrayList<>()); ```1.7 在可变参数方法中传递非具体化参数,改进编译警告和错误Heap pollution 指一个变量被指向另外一个不是相同类型的变量。例如```List l = new ArrayList<Number>();List<String> ls = l;       // unchecked warningl.add(0, new Integer(42)); // another unchecked warningString s = ls.get(0);      // ClassCastException is thrownJdk7:public static <T> void addToList (List<T> listArg, T... elements) {for (T x : elements) {listArg.add(x);}}```> 你会得到一个warningwarning: [varargs] Possible heap pollution from parameterized vararg type要消除警告,可以有三种方式1.加 annotation @SafeVarargs2.加 annotation @SuppressWarnings({"unchecked", "varargs"})3.使用编译器参数 –Xlint:varargs;1.8  信息更丰富的回溯追踪 就是上面try中try语句和里面的语句同时抛出异常时,异常栈的信息```java.io.IOException  *     at Suppress.write(Suppress.java:19)  *      at Suppress.main(Suppress.java:8)  *      Suppressed:  java.io.IOException *          at Suppress.close(Suppress.java:24) *          at Suppress.main(Suppress.java:9)  *      Suppressed:  java.io.IOException *          at  Suppress.close(Suppress.java:24)  *          at  Suppress.main(Suppress.java:9) ```2. ThreadLocalRandon 并发下随机数生成类,保证并发下的随机数生成的线程安全,实际上就是使用threadlocal

final int MAX = 100000;
ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();
long start = System.nanoTime();
for (int i = 0; i < MAX; i++) {
threadLocalRandom.nextDouble();
}
long end = System.nanoTime() - start;
System.out.println("use time1 : " + end);
long start2 = System.nanoTime();
for (int i = 0; i < MAX; i++) {
Math.random();
}
long end2 = System.nanoTime() - start2;
System.out.println("use time2 : " + end2);
```

转载于:https://www.cnblogs.com/f-s-q/p/6597742.html

http://www.jmfq.cn/news/5149351.html

相关文章:

  • 一个网站的后台/拉新平台
  • 网站制作三站/青岛网站开发公司
  • 长沙做网站湖南微联讯点不错/2023年3月份疫情严重
  • 柳州市城乡建设委员会网站/重庆百度seo代理
  • 安徽网站建设费用/徐州seo排名公司
  • 公司网站建设及维护管理总结/网络营销软文范例300
  • 外贸网站建设需要注意什么/云南网站seo服务
  • 北京知名seo公司精准互联/seo做什么网站赚钱
  • 机箱做的网站主机怎么查看ftp/班级优化大师电脑版
  • 织梦 xml网站地图/搜狗收录提交入口
  • wap网站方案/西安seo经理
  • 滨江做网站/淘宝关键词优化
  • 赤峰市建设网站/seow是什么意思
  • wordpress 插件 表/吉林seo基础知识
  • 丝绸之路网站建设策划书/网站制作需要多少钱
  • 淘宝客高佣金网站建设/中国万网域名注册官网
  • 湖北网站建设价格/营销推广计划书
  • wordpress 搞笑网站/seo页面内容优化
  • wordpress 滑块如何使用/seo网站推广方案
  • 番禺 大石网站建设/短视频代运营方案策划书
  • 南阳手机网站制作/湖南网站建设营销推广
  • 宁波网站推广方案/河南靠谱seo地址
  • 网站做app的重要性/上海seo公司哪个靠谱
  • 做网站需要用到那些软件/广州今日刚刚发生的新闻
  • 找潍坊做网站的/百度搜索量查询
  • 怎么改网站模板/百度手机助手官网
  • wordpress博客 翻墙/武汉seo公司排名
  • 网站首页横版图怎么做/seo还能赚钱吗
  • 图文视频怎么制作/企业网站seo点击软件
  • 山东做网站找哪家好/网站seo快速排名优化