Scanner class.
next() 与 nextLine()
The method of acquiring the input character string, before reading the data we typically requires the use hasNext whether there is an input to the determination hasNextLine
math
Math
random
Random
Math
random
Random
Arrays
(1,2,3,4,5)
(1,2,3,4,5)
str = "xiaojiejie"
String
nextInt ()
hasNextInt()
false false false
TRUE true True
98
nextInt ()
nextInt ()
abc
hasNextInt()
if(hasNextInt()){
nextInt()
}else{
"错了。"
}
String
next().charAt(0)
nextInt()
}else{
"错了。"
}
String
next().charAt(0)
charAt(index)
Java exception handling
array subscript bounds exception.
ArrayIndexOutOfBoundsException
array subscript bounds exception.
ArrayIndexOutOfBoundsException
Runtime
ArithmeticException
When the exceptional arithmetic condition occurs, Thrown. For example, an integer "divide by zero" throws an instance of this class
5/0
ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException
Access abnormal thrown when an array with an illegal index.
If the index is greater than or equal to the array size of the negative, the index is invalid index.
If the index is greater than or equal to the array size of the negative, the index is invalid index.
When ClassCastException when trying to cast an object is not an instance of a subclass thrown exception.
Cast
铸造; 投掷; 投射; 脱落,脱皮;
n. 铸型; 演员表; 轻微的斜视; 投,掷骰;
vi. 掷,投; 计算,加;
铸造; 投掷; 投射; 脱落,脱皮;
n. 铸型; 演员表; 轻微的斜视; 投,掷骰;
vi. 掷,投; 计算,加;
IndexOutOfBoundsException
指示某排序索引(例如对数组、字符串或向量的排序)超出范围时抛出。
NullPointerException 当应用程序试图在需要对象的地方使用 null 时,抛出该异常
NumberFormatException
Format
使格式化; 安排…的格局; 设计…的版面;
vi. 设计一个版式;
当应用程序试图将字符串转换成一种数值类型,但该字符串不能转换为适当格式时,抛出该异常。
Format
使格式化; 安排…的格局; 设计…的版面;
vi. 设计一个版式;
当应用程序试图将字符串转换成一种数值类型,但该字符串不能转换为适当格式时,抛出该异常。
ClassNotFoundException 应用程序试图加载类时,找不到相应的类,抛出该异常。
Found
发现( find的过去式); 找到; 到达; 发觉;
发现( find的过去式); 找到; 到达; 发觉;
NoSuchFieldException
Such
请求的变量不存在
Such
请求的变量不存在
NoSuchFieldException
num ==
Field 状态。
类里面的。
类里面的。
变量。
田; (作某种用途的)场地; (学习或研究的)领域; 运动场;
vi. [棒球、板球等]担任外场员,担任守队队员; 接守,接防; 接,掷还(球);
adj. 实地的; [体育]1)。 在田赛场地进行的2)。 田赛的; 军事]野战的; 在实地工作的;
vt. 保护; 把(农作物等)晒在场上; [棒球、板球等]按(或截)(球); 即席圆满回答;
变形 过去分词: fielded 复数: fields 过去式: fielded 现在分词: fielding 第三人称单数: fields
vi. [棒球、板球等]担任外场员,担任守队队员; 接守,接防; 接,掷还(球);
adj. 实地的; [体育]1)。 在田赛场地进行的2)。 田赛的; 军事]野战的; 在实地工作的;
vt. 保护; 把(农作物等)晒在场上; [棒球、板球等]按(或截)(球); 即席圆满回答;
变形 过去分词: fielded 复数: fields 过去式: fielded 现在分词: fielding 第三人称单数: fields
NoSuchMethodException 请求的方法不存在
Method
方法; 条理;
funtion 函数。
method
funtion
method
funtion
public String getMessage()
返回关于发生的异常的详细信息。这个消息在Throwable 类的构造函数中初始化了。
返回关于发生的异常的详细信息。这个消息在Throwable 类的构造函数中初始化了。
Message 信息; 消息; 要旨; 教训;
public Throwable getCause()
返回一个Throwable 对象代表异常原因。
返回一个Throwable 对象代表异常原因。
Cause
原因; 动机; 理由; 事业;
vt. 成为…的原因; 导致; 引起; 使遭受;
vt. 成为…的原因; 导致; 引起; 使遭受;
public String toString()
使用getMessage()的结果返回类的串级名字。
使用getMessage()的结果返回类的串级名字。
String toString()
返回该对象的字符串表示。
next().charAt(index)
返回该对象的字符串表示。
next().charAt(index)
getClass().getName() + '@' +
Integer.toHexString(hashCode())
Integer.toHexString(hashCode())
类名 @
98
toHexString( hashCode() )
A (B)
装饰。
装饰。
a = fun()
sum(fun())
sum(a,2)
sum(5,2)
sum(fun())
sum(a,2)
sum(5,2)
try
{
// 程序代码
}catch(ExceptionName e1)
{
//Catch 块
}
{
// 程序代码
}catch(ExceptionName e1)
{
//Catch 块
}
try{
// 程序代码
}catch(异常类型1 异常的变量名1){
// 程序代码
}catch(异常类型2 异常的变量名2){
// 程序代码
}catch(异常类型2 异常的变量名2){
// 程序代码
}
// 程序代码
}catch(异常类型1 异常的变量名1){
// 程序代码
}catch(异常类型2 异常的变量名2){
// 程序代码
}catch(异常类型2 异常的变量名2){
// 程序代码
}
Exception
声明自定义异常
AgeOutOfBoundsException
Exception