求教,错误java.lang.NoSuchMethodError: main Exception in thread "main&qu

[复制链接]
查看11 | 回复4 | 2021-1-27 06:46:07 | 显示全部楼层 |阅读模式
packagea;
importjava.util.Scanner;
publicclassl{
publicstaticvoidmain(Stringstr){
System.out.print("输入");
Scannerscan=newScanner(System.in);
str=scan.next();
System.out.print(str);
}
}

分 -->
回复

使用道具 举报

千问 | 2021-1-27 06:46:07 | 显示全部楼层
把第四行的str改成arg[]试一下
回复

使用道具 举报

千问 | 2021-1-27 06:46:07 | 显示全部楼层
刚刚说错了,应该这样改publicstaticvoidmain(String[]args)
回复

使用道具 举报

千问 | 2021-1-27 06:46:07 | 显示全部楼层
你写的main方法有问题啊
应该是publicstaticvoidmain(String[]args){}
参数必须是一个String类型的数组
回复

使用道具 举报

千问 | 2021-1-27 06:46:07 | 显示全部楼层
publicstaticvoidmain(String[]args){}写这段代码的时候,不用一个个代码敲,有快捷方法的,写main按Alt+?回车就出来了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行