Java学习篇-------理解异常
2015-07-15 17:41
489 查看
import java.util.Scanner;
public class QISHIWU {
public static void main(String[] args)
{
Scanner scan=new Scanner(System.in);
int a,b;
a=scan.nextInt();
b=scan.nextInt();
try{
if(a>b)
System.out.println("二者相等");
else
System.out.println("二者不等");
}
catch(Exception e){
e.PrintStrackTrace(); // 记住每一个异常,都有一个异常对象对应,用于作为catch()方法的参数,参数类型为:Exception类型 。
// 每一个异常对象,都有它的异常处理方法。用于在catch()方法内调用该异常对象的相应方法。
}
}
}
/*Multiple markers at this line
- exception cannot be resolved to a type
- Syntax error on token "exception", VariableDeclaratorId expected after this
token
*/ //这句话的意思是说,exception 不是一个数据类型。
public class QISHIWU {
public static void main(String[] args)
{
Scanner scan=new Scanner(System.in);
int a,b;
a=scan.nextInt();
b=scan.nextInt();
try{
if(a>b)
System.out.println("二者相等");
else
System.out.println("二者不等");
}
catch(Exception e){
e.PrintStrackTrace(); // 记住每一个异常,都有一个异常对象对应,用于作为catch()方法的参数,参数类型为:Exception类型 。
// 每一个异常对象,都有它的异常处理方法。用于在catch()方法内调用该异常对象的相应方法。
}
}
}
/*Multiple markers at this line
- exception cannot be resolved to a type
- Syntax error on token "exception", VariableDeclaratorId expected after this
token
*/ //这句话的意思是说,exception 不是一个数据类型。
相关文章推荐
- Java中的重载、重写、多态,静态绑定、动态绑定
- Java NIO原理图文分析及代码实现
- Spring -- IOC理论
- How-to: resolve "java.lang.NoClassDefFoundError: org/htrace/Trace" when hbase Export
- springmvc DispatcherServlet初始化..信息..
- 堆(heap)
- Java学习------基本数据类型转换
- 001--jdk环境配置
- OpenJWeb3.1 Java Web应用快速开发平台全部开源公告
- java timer类
- eclipse 注释模板设置详解
- JAVA环境安装配置
- struts2 通配符的配置方式
- Java中的重载、重写、多态,静态绑定、动态绑定
- eclipse 添加注释简介
- java-泛型返回值的方法类型
- java Runtime.exec() 执行问题
- java web每天定时执行任务
- java 命令参数知识
- java的线程通信