zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然JAVA数组与方法学习笔记:java新特性对数组的支持

    public class NewDemo01{
        public static void main(String args[]){
            System.out.print("不传递参数(fun()):") ;
            fun() ;            // 不传递参数
            System.out.print("
    传递一个参数(fun(1)):") ;
            fun(1) ;        // 传递一个参数
            System.out.print("
    传递五个参数(fun(1,2,3,4,5)):") ;
            fun(1,2,3,4,5) ;
        }
        public static void fun(int ... arg){    // 可变参数
            for(int i=0;i<arg.length;i++){        // 循环输出
                System.out.print(arg[i] + "、") ;
            }
        }
    };
    public class NewDemo02{
        public static void main(String args[]){
            System.out.print("不传递参数(fun()):") ;
            fun() ;            // 不传递参数
            System.out.print("
    传递一个参数(fun(1)):") ;
            fun(1) ;        // 传递一个参数
            System.out.print("
    传递五个参数(fun(1,2,3,4,5)):") ;
            fun(1,2,3,4,5) ;
        }
        public static void fun(int ... arg){    // 可变参数
            for(int x:arg){        // 使用foreach输出输出
                System.out.print(x + "、") ;
            }
        }
    };
  • 相关阅读:
    【JSP】jQuery Deferred exception successed is not defined
    onclick事件传递变量参数&拼接字符串
    JQuery
    设计模式
    拖拽-原型继承案例
    继承
    原型
    闭包
    promise
    jsonp
  • 原文地址:https://www.cnblogs.com/tszr/p/12435792.html
Copyright © 2011-2022 走看看