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

  • Post author:
  • Post category:java




错误提示:


类型:。。。。。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);






}







}



版权声明:本文为H002399原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。