码迷,mamicode.com
首页 > 编程语言 > 详细

java特性

时间:2016-01-27 10:47:16      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

1.import static导入静态方法

import static java.util.Arrays.*;

public class Example {

    public static void main(String[] args) {
        int[] target = new int[]{5,4,7};
        sort(target);
        
        for (int i = 0; i < target.length; i++) {
            System.out.println(target[i]);
        }
    }

}

 

2.可变参数 Object...

public class Example2 {
    
    public static void speak(String speaker, String... words){
        for (int i = 0; i < words.length; i++) {
            System.out.println(speaker+":"+words[i]);
        }
    }
    
    public static void main(String[] args) {
        String sentence = "I am a slow walker , but I never walk backwards .";        
        speak("Lincoln", sentence.split(","));
    }
}

 

java特性

标签:

原文地址:http://www.cnblogs.com/barker/p/5162372.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!