可变参数
定义方式类型后急加三个点。
隐式将参数封装成数组
注意可变参数要放在参数列表的最后边
例如
public static void show (int... arr){
}
show(1,2,3,)
show(6,5,4,7,8)
静态导入
import static java.lang.System.*//导出了System类中所有的静态成员
当类名重名时,要指定具体的包名
当方法重名时,指定具体所属的对象或类
import static java.lang.System.*//导出了System类中所有的静态成员
import static java.until.Arrays.*//
public class StaticImport{
public static void main(String[] args){
int[] arr = {4,2,3,1};
//Arrays.sort(arr);
sort(arr);
int index = binarySearch(arr,1);
System.out.println(Arrays.toString(arr))//当方法重名时,指定具体所属的对象或类
out.println("index="+index);
}
}
定义方式类型后急加三个点。
隐式将参数封装成数组
注意可变参数要放在参数列表的最后边
例如
public static void show (int... arr){
}
show(1,2,3,)
show(6,5,4,7,8)
静态导入
import static java.lang.System.*//导出了System类中所有的静态成员
当类名重名时,要指定具体的包名
当方法重名时,指定具体所属的对象或类
import static java.lang.System.*//导出了System类中所有的静态成员
import static java.until.Arrays.*//
public class StaticImport{
public static void main(String[] args){
int[] arr = {4,2,3,1};
//Arrays.sort(arr);
sort(arr);
int index = binarySearch(arr,1);
System.out.println(Arrays.toString(arr))//当方法重名时,指定具体所属的对象或类
out.println("index="+index);
}
}