更换了JRE设置,突然报了好多错,如:Type mismatch: cannot convert from long to Long之类

chuzhaoqi025 2017-01-16 05:37:20
一个小程序 没写完 诸如此类 ,如果是JRE错误 怎么办?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class MatrixTrace {
public static void main(String[] args) throws IOException {
int n;
long sum=0;
System.out.print("进行数据输入:");
Scanner num=new Scanner(System.in);
n=num.nextInt();
String s[]=new String[n];
Scanner scan[]=new Scanner[n];
Long W[][]=new Long[n][n];
BufferedReader std=new BufferedReader(new InputStreamReader(System.in));

for(int i=0;i<n;i++) {
s[i]=std.readLine();
}

System.out.println("输入的数据为:");
for(int i=0;i<n;i++) {

scan[i]=new Scanner(s[i]);

}
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
W[i][j]=scan[i].nextLong();

}
}
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
System.out.print(W[i][j]+" ");
if (i==j) {
sum=sum+W[i][j];
}
}
System.out.println("");

}
System.out.println("he:"+sum);

}
}
...全文
944 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
解开者 2017-01-16
  • 打赏
  • 举报
回复
Type mismatch: cannot convert from long to Long 这个问题应该只有小于1.5的版本才会出现,1.5新增的autobox特性已经能自动添加转换代码

50,523

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧