首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    《Perl语言入门》——读书笔记

    Perl语言入门 /** * prism.js Github theme based on GitHub's theme. * @author Sam Clarke */ code[class*="language-"], pre[class*="language-"] { color: #333; background: none; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; word-wrap: normal; line-height: 1.4; -moz-tab-size: 8; -o-tab-size: 8; tab-size: 8; -webkit-hyphens: none; -moz-hyphens: none; -ms-hyphens: none; hyphens: none; } /* Code blocks */ pre[class*="language-"] { padding: .8em; overflow: auto; /* border: 1px solid #ddd; */ border-radius: 3px; /* background: #fff; */ background: #f5f5f5; } /* Inline code */ :not(pre) > code[class*="language-"] { padding: .1em; border-radius: .3em; white-space: normal; background: #f5f5f5; } .token.comment, .token.blockquote { color: #969896; } .token.cdata { color: #183691; } .token.doctype, .token.punctuation, .token.variable, .token.macro.property { color: #333; } .token.operator, .token.important, .token.keyword, .token.rule, .token.builtin { color: #a71d5d; } .token.string, .token.url, .token.regex, .token.attr-value { color: #183691; } .token.property, .token.number, .token.boolean, .token.entity, .token.atrule, .token.constant, .token.symbol, .token.command, .token.code { color: #0086b3; } .token.tag, .token.selector, .token.prolog { color: #63a35c; } .token.function, .token.namespace, .token.pseudo-element, .token.class, .token.class-name, .token.pseudo-class, .token.id, .token.url-reference .token.variable, .token.attr-name { color: #795da3; } .token.entity { cursor: help; } .token.title, .token.title .token.punctuation { font-weight: bold; color: #1d3e81; } .token.list { color: #ed6a43; } .token.inserted { background-color: #eaffea; color: #55a532; } .token.deleted { background-color: #ffecec; color: #bd2c00; } .token.bold { font-weight: bold; } .token.italic { font-style: italic; } /* JSON */ .lan

    02

    JDK1.7新特性

    1 对集合类的语言支持;  2 自动资源管理;  3 改进的通用实例创建类型推断;  4 数字字面量下划线支持;  5 switch中使用string;  6 二进制字面量;  7 简化可变参数方法调用。     下面我们来仔细看一下这7大新功能:  1 对集合类的语言支持        Java将包含对创建集合类的第一类语言支持。这意味着集合类的创建可以像Ruby和Perl那样了。        原本需要这样:           List<String> list = new ArrayList<String>();           list.add("item");           String item = list.get(0);           Set<String> set = new HashSet<String>();           set.add("item");           Map<String, Integer> map = new HashMap<String, Integer>();           map.put("key", 1);           int value = map.get("key");        现在你可以这样:           List<String> list = ["item"];           String item = list[0];           Set<String> set = {"item"};           Map<String, Integer> map = {"key" : 1};           int value = map["key"];        这些集合是不可变的。  2 自动资源管理        Java中某些资源是需要手动关闭的,如InputStream,Writes,Sockets,Sql classes等。这个新的语言特性允许try语句本身申请更多的资源,     这些资源作用于try代码块,并自动关闭。        这个:           BufferedReader br = new BufferedReader(new FileReader(path));           try {           return br.readLine();                 } finally {                     br.close();           }        变成了这个:            try (BufferedReader br = new BufferedReader(new FileReader(path)) {               return br.readLine();            }        你可以定义关闭多个资源:           try (               InputStream in = new FileInputStream(src);               OutputStream out = new FileOutputStream(dest))           {           // code           }        为了支持这个行为,所有可关闭的类将被修改为可以实现一个Closable(可关闭的)接口。  3 增强的对通用实例创建(diamond)的类型推断        类型推断是一个特殊的烦恼,下面的代码:           Map<String, List<String>> anagrams = new HashMap<String, List<String>>();        通过类型推断后变成:           Map<String, List<String>> anagrams = new HashMap<>();        这个<>被叫做diamond(钻石)运算符,这个运算符从引用的声明中推断类型。        很长的数字可读性不好,在Java 7中可以使用下划线分隔长int以及long了,如:           int one_million = 1_000_000;     运算时先去除下划线,如:1_1 * 10 = 110,120 – 1_0 = 110    5 switch中使用string       以前你在switch中只能使用number或enum。现在你可以使用string了:           String s = ...           switch(s) {

    02

    扫码

    添加站长 进交流群

    领取专属 10元无门槛券

    手把手带您无忧上云

    扫码加入开发者社群

    相关资讯

    热门标签

    活动推荐

      运营活动

      活动名称
      广告关闭
      领券