求解答java.lang.NumberFormatException: For input string: "姚雪娟"類異常
else if(OPERATION_UPDATE.equals(in.toUpperCase())
?????||OPERATION_UPDATE.substring(0, 1).equals(in.toUpperCase())
?????||OPERATION_UPDATE.equals(pervious)){
????pervious=OPERATION_UPDATE;
????if(1==step){
?????System.out.println("請輸入要修改的員工ID:");
????}else if(2==step){
?????Integer id=null;
?????try {
??????id = Integer.valueOf(in);
??????try {
???????user = action.getById(id);
???????if(user==null){
????????System.out.println("查詢員工信息失敗");
????????step=1;
???????}else{
????????System.out.println("請輸入新的員工信息[姓名]:");
???????}
??????} catch (Exception e) {
???????System.out.println("查詢員工信息失敗");
???????step=1;
??????}
?????} catch (Exception e) {
??????System.out.println("請輸入正確的員工ID:");
??????step=1;
?????}
?????
????}else if(3==step){
?????System.out.println(in);
?????if(-1!=Integer.valueOf(in)){
??????user.setName(in);
?????}???
?????System.out.println("請輸入新的員工信息[性別]:");
????}
這是view層一段代碼,運行update方法時,當輸入姓名為:姚雪娟時,提示
Exception in thread "main" java.lang.NumberFormatException: For input string: "姚雪娟"
?at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
?at java.lang.Integer.parseInt(Integer.java:449)
?at java.lang.Integer.valueOf(Integer.java:554)
?at com.view.View.main(View.java:218)
這是怎么回事?
2016-11-16
使用了,Integer.parseInt(String sb)
sb傳入的值是:姚雪娟,應該輸入一個整數范圍的數字 (-2^31)到(2^31-1).
2016-08-15
NumberFormatException: 明顯數據轉換異常啊
2016-03-06
2015-07-22
?"姚雪娟"?不能轉換為數字,你看看邏輯是不是有問題,你的代碼太長了