我不得不用一些代码回答这个问题:
假设我编写了以下方法规范:
public void manipulateData ( ) throws java.sql.SQLException, java.sql.SQLDataException您正在编写将使用此方法的数据库程序的代码,并且您希望专门处理每个方法.try/catch子句应该是什么样的?
您可以使用no-ops-- empty blocks {} - 用于catch子句内容.
我们只对这里语句的语法和结构感兴趣.
我回答说:
try {
} catch(java.sql.SQLException e) {
}
catch(java.sql.SQLDataException e) {
}
Run Code Online (Sandbox Code Playgroud)
由于这个原因,他没有接受答案:
"你的捕获条款的顺序是错误的.你能解释为什么这个命令很重要吗?"
他的答案是否正确?
Error Message:
Exception in thread "main" java.lang.NumberFormatException: For input string: "Ace of Clubs"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at set07102.Cards.main(Cards.java:68)
C:\Users\qasim\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)
Run Code Online (Sandbox Code Playgroud)
我的循环:
while (response != 'q' && index < 52) {
System.out.println(cards[index]);
int first_value = Integer.parseInt(cards[index]);
int value = 0;
//Add a Scanner
Scanner scanner = new Scanner(System.in);
System.out.println("Will the next card be higher or lower?, press q if you want to quit");
String guess = scanner.nextLine();
if(cards[index].startsWith("Ace")) { value …Run Code Online (Sandbox Code Playgroud)