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

//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),


}


}

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值