爱问知识人 爱问教育 医院库

5语言有哪些新特性?

首页

5语言有哪些新特性?

Java1.5语言有哪些新特性?

提交回答

全部答案

    2017-07-27 23:22:51
  •   1。 自动装箱与拆箱 对应C#
    例1。1
    Integer i = 10;
    int j = i;
    2。 更优化的for循环 对应就C#---foreach循环
    例2。1
    String[] names = {"BadBoy","GoodBoy","HappyGirl","sadGirl"};
    for(String option: names) {
    System。
      out。println(option); } 例2。2 加泛型 对应C++模板 import java。util。*; ArrayList animals = new ArrayList(); animals。add("Dog"); animals。
      add("Cat"); animals。add("Chick"); animals。add("Cow"); for(String option : animals) { System。out。println(option); } 3。
      参数可变的方法和printf 例3。1 定义: public int sum(int。。。 n) { //传过来n为一个int型数组 int tempSum; for(int option : n) { tempSum+=option; } /* for(int i = 0; i < n。
      length; i++) { tempSum+=n; } */ return tempSum; } 调用1: sum (1); 调用2: sum(1,2); 调用3: sum(1,2,3,4); 例3。2 printf方法, 对应c语言的printf int x = 10; int y = 20; int sum = x + y; System。
      out。printf("%d + %d = %d",x,y,sum);。

    瑾***

    2017-07-27 23:22:51

类似问题

换一换
  • 系统软件 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):