myexception.java
来自「本java源程序包括了大量的学习程序(共27章)方便大家学习」· Java 代码 · 共 29 行
JAVA
29 行
public class MyException
{
public static void main(String argv[])
{
String str = "2abcde";
try
{
char c = str.charAt(0);
if(c<'a'||c>'z'||c<'A'||c>'Z')
throw new FirstLetterException();
}
catch(FirstLetterException e)
{
System.out.println("This is FirstLetterException");
}
}
}
class FirstLetterException extends Exception
{
public FirstLetterException()
{
super("The first char is not a letter");
}
public FirstLetterException(String str)
{
super(str);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?