小编Pri*_*nce的帖子

十三个9s的产品在java中的两种方法都不同

public class Main {

    public static void main(String[] args) {

        long product = 1L;
        product = (9 * 9 * 9 * 9 * 9 * 9 * 9 * 9 * 9 * 9 * 9 * 9 * 9);
        System.out.println(product);
        product = 9L;
        for (int i = 0; i != 12; i++) {
            product *= 9;
        }
        System.out.println(product);

    }
}
Run Code Online (Sandbox Code Playgroud)

输出:-754810903
2541865828329 //这个是正确的

java

4
推荐指数
2
解决办法
97
查看次数

为什么数组没有在javacode下面排序?

当我运行代码时,数组p没有排序.我弄清楚了

为什么会这样?

import java.util.Arrays;

public class Main {

    public static void main (String[] args){

        //creating array p
        int[] p= new int[] {2,7,8,3,9,1,4,5,6,0 };

        //sort p[5] to p[9]
        Arrays.sort(p, 5, 9);
        for(int l=0;l<p.length;l++)
        {
            System.out.print(p[l]);
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

输出为:2783914560

java

-6
推荐指数
1
解决办法
72
查看次数

标签 统计

java ×2