当它们在前面的方括号时是什么意思double.例如double[]
,在方法中使用return函数时是否有任何特殊的方法可以使用它们.
例如:
public double[] MethodName(){
}
Run Code Online (Sandbox Code Playgroud)
返回值的类型是什么?
我正在研究一个搜索数组并找到最小值的程序,然后打印出运行器的time,firstName和lastName.
我需要弄清楚的是如何在不同的行上返回三个值,如:
public String toString() {
return String.format( firstName + " " + lastName + " " + Time );
}
Run Code Online (Sandbox Code Playgroud)
这就是我现在所拥有的
有没有办法让三个值在不同的行上打印出来?
我这里有一个Arraylist:
public static void main(String[] args) {
Person P1 = new Person("Nathen", 144.5, 55.1);
Person P2 = new Person("Jamie", 133, 60);
Person P3 = new Person("Tom", 134, 65);
Person P4 = new Person("Lavi", 170, 70);
ArrayList<String> Person = new ArrayList<String>();{
Person.add(P1.getCategory());
Person.add(P2.getCategory());
Person.add(P3.getCategory());
Person.add(P4.getCategory());
}
System.out.println(Person);
}
Run Code Online (Sandbox Code Playgroud)
如何让程序一次打印出Arraylist一行而不是我现在的一行.