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),
}
}
/*错误分析:
* 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),
}
}
相关文章推荐
- 读配置文件可以保持顺序的 Java Properties 类
- 编写一个程序,将 d: \ java 目录下的所有.java 文件复制到d: \ jad 目录下,并 将原来文件的扩展名从.java 改为.jad
- 深入浅出 Java Concurrency (6): 锁机制 part 1
- java枚举类型enum的使用
- Java常见内存溢出异常分析(OutOfMemoryError)
- AOP Spring
- Springmvc JSON交互
- 【转】Java并发编程:Thread类的使用
- Java项目经验
- `java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener`
- Spring MVC重定向
- Java opencv中sift的实现
- 【转】深入理解java异常处理机制
- Java深入 - logback的配置和使用
- Maven 项目在集成Eclipse环境报错
- 网易云课堂java进阶 编程题
- java,spring定时任务
- [转]Eclipse编码格式修改
- java控制语句
- 【转】Java并发编程:volatile关键字解析