java问题,不懂,求大神赐教,问题如下:
publicclassHelloWorld{publicstaticvoidmain(String[]args){double[]nums={1.4,1.5,1.6,-1...
public class HelloWorld{
public static void main(String[] args) {
double[] nums = { 1.4, 1.5, 1.6, -1.4, -1.5, -1.6 };
for (double num : nums) {
test(num);
}
}
private static void test(double num) {
System.out.println("Math.floor(" + num + ")=" + Math.floor(num));
System.out.println("Math.round(" + num + ")=" + Math.round(num));
System.out.println("Math.ceil(" + num + ")=" + Math.ceil(num));
}
}
for (double num : nums)这句不知道什么意思? 展开
public static void main(String[] args) {
double[] nums = { 1.4, 1.5, 1.6, -1.4, -1.5, -1.6 };
for (double num : nums) {
test(num);
}
}
private static void test(double num) {
System.out.println("Math.floor(" + num + ")=" + Math.floor(num));
System.out.println("Math.round(" + num + ")=" + Math.round(num));
System.out.println("Math.ceil(" + num + ")=" + Math.ceil(num));
}
}
for (double num : nums)这句不知道什么意思? 展开
1个回答
2015-03-22
展开全部
这是增强for循环,
意思就是遍历nums, 每次循环时从nums中取出的元素赋给num.
意思就是遍历nums, 每次循环时从nums中取出的元素赋给num.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询