Java错误提示-------。。。。。cannot be resolved 。???

错误提示:

类型:。。。。。cannot be resolved 。

原因分析:

/*凡是提示:。。。。。cannot be resolved 。这样的错误都是:
* 1.变量没有声明或定义就直接使用。
* 2.某一个类,没有导入或定义
* 3.某一对象,没有定义或声明。


*/


具体项目中举例:


import java.util.Scanner;
public class AppCAC
{
public static int Avg(int temp)
{
int avg1;
avg1=temp; // 当这样写时:avg1=temp; 显示的错误是: avg1 cannot be resolved  // 即:avg1不能被处理。
avg1=avg1+temp;

return avg1;
}


public static int Max(int  temp)
{
int M=0;
if(temp>=M)
M=temp;
return M;


}


public static int Min(int temp)
{
int Min=0;
if(Min>=temp)
{
Min=temp;
}
return Min;
}








public static void main(String[] args)
{
int com;
int avg;
int max;
int min;
// 在这里我要定义三个方法
//如何定义方法?: 修饰符   返回值类型   方法名(参数列表)

/*Scanner scan=new Scanner(System.in);这句话的错误是:Multiple markers at this line
- Scanner cannot be resolved to 
a type*/


for(int i=1;i<11;i++)
{
System.out.println("请输入:");
// com=scan.nextInt(); 这句代码报错:scan cannot be resolved  scan 不能被处理,我总结如下:

/*凡是提示:。。。。。cannot be resolved 。这样的错误都是:
* 1.变量没有声明或定义就直接使用。
* 2.某一个类,没有导入或定义
* 3.某一对象,没有定义或声明。


*/
    Avg(com);
Max(com);
Min(com);
}
/*for(i=1;i<11;i++)
{
System.out.println("请输入:");
com=scan.nextInt();
    Avg(com);
Max(com);
Min(com);
}
这段代码显示:Multiple markers at this line
- i cannot be 
resolved
- i cannot be 
resolved
- i cannot be 
resolved
 
这样的错误, :错误: i不能被处理。为什么i不能被处理?? ? 原因是: 我没有定义i就使用了,变量只有定义了才能使用。
*
*/
avg=Avg/10;
System.out.println("现在开始输出:\n");
System.out.println("平均数为:" ,avg);
System.out.println("最大值为:",Max);//提示出错:The method println(int) in the type PrintStream is not applicable for the arguments (String, int),
// 学习一下,println方法的使用了.

System.out.println("最小值为:",Min);

}


}


  • 9
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值