• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

概念:可接收多个同类型实参,个数不限,使用方式与数组相同

语法:数据类型.形参名//必须定义在形参列表的最后,且只能有一个

公共类测试{

公共静态void main(String[] args){

int[] numbrs={1,2,3,4,5,6 };

//支持数组类型的实参

方法(数字);

//支持传递零散数据的实参

方法(5,6,7,8,9,10);

int[] newArr=expand(100,numbrs);

}

//函数的参数是"可变长参数"

公共静态空的方法(int.arr){

for(int I=0;iarr。长度;i ){

系统。出去。print(arr' \ t ');

}

}

//int.=int[] String.=String[] char.=char[] double.=double[]

public static int[]expand(int length,int[] arr){//只能有一个,必须在列表最后

int[]new nums=new int(length);

System.arraycopy(arr,0,newNums,0,arr。长度);

返回新Nums

}

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now