Tag: 组长

可能有损转换从long到int

我希望输入一个int和另一个long ex:1和1000000000,现在我希望创建一个大小为1000000000的数组。然后在数组的每个索引处,存储int val,ex: arr[100000000] = 4 。 当我试图这样做时,Netbeans在这一行显示错误: arr = new long[y+1]` and `arr[j] = 0` “从long到int可能有损转换”。 这是我的代码: – public static void main(String[] args) throws IOException { BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); String[] xe = s.readLine().split(” “); int x = Integer.parseInt(xe[0]); long y = Long.parseLong(xe[1]); long []arr; arr = new long[y+1]; for(long j=0;j<=y;j++) arr[j] […]