您的位置:首页 > 编程语言 > Java开发

Java错误提示------println()错误

2015-07-15 15:43 621 查看
//System.out.println("平均数为:" ,avg);提示出错:The method println(int) in the type PrintStream is not applicable for the arguments (String, int)

/*错误分析:

* 1.因文解释:

* ().argument英 ['ɑ:ɡjʊmənts] 美 ['ɑ:ɡjʊmənts]

n. 争论( argument的名词复数 );争吵;说理;论据

().applicable英 [əˈplɪkəbl] 美 [ˈæplɪkəbəl, əˈplɪkə-] adj. 适当的;可应用的

* 2.翻译:println()方法不适用于(String,int)这样用法。即:println使用错误。

*

*

*/

源代码如下:

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.某一对象,没有定义或声明。

*

*

*/

}

for(int i=1;i<11;i++)

{

System.out.println("请输入:");

Scanner scan=new Scanner(System.in);

com=scan.nextInt();

// com=scan.nextInt();报错:scan cannot be resolved

avg= Avg(com);

max=Max(com);

min= 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();这一句也报错:错误提示:Multiple markers at this line

- The method Avg(int) in the type AppCAC is not applicable for the

arguments ()

*/

System.out.println("现在开始输出:\n");

//System.out.println("平均数为:" ,avg);提示出错:The method println(int) in the type PrintStream is not applicable for the arguments (String, int)

/*错误分析:

* 1.因文解释:

* ().argument英 ['ɑ:ɡjʊmənts] 美 ['ɑ:ɡjʊmənts]

n. 争论( argument的名词复数 );争吵;说理;论据

().applicable英 [əˈplɪkəbl] 美 [ˈæplɪkəbəl, əˈplɪkə-] adj. 适当的;可应用的

* 2.翻译:println()方法不适用于(String,int)这样用法。即:println使用错误。

*

*

*/

System.out.println("最大值为:");//提示出错:The method println(int) in the type PrintStream is not applicable for the arguments (String, int),

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: