ループでnの数を増やしていってallRowListの中身がなくなったら
ループを脱出しようと考えていましたが、
indexoutofboundsexception
というエラーが出ました。
存在しないインデックスを指定するとでるエラーらしいです。
代わりにallRowListの中身がなくなったらループを抜けられるようにするにはどうしたらいいでしょうか。
java
1package save.function; 2 3public class JudgeName { 4 HoldResult holdResult; 5 6 public JudgeName( HoldResult holdResult) { 7 this.holdResult = holdResult; 8 } 9 10 public void judgeName() { 11 int n = 0; 12 while ( true) { 13 try { 14 if (holdResult.allRowList.get( n) != null) { 15 16 if ( holdResult.allRowList.get( n).get( 0).equals( holdResult.getPlayerName())) { 17 holdResult.setExistsTheName( true); 18 holdResult.setTotalWin( Integer.parseInt( holdResult.allRowList.get( n).get( 1)) + holdResult.getTotalWin()); 19 holdResult.setTotalLose( Integer.parseInt( holdResult.allRowList.get( n).get( 2)) + holdResult.getTotalLose()); 20 } 21 else { 22 holdResult.getRemovedList().add( holdResult.allRowList.get( n).get( 0) + ","); 23 holdResult.getRemovedList().add( holdResult.allRowList.get( n).get( 1) + ","); 24 holdResult.getRemovedList().add( holdResult.allRowList.get( n).get( 2) + "\n"); 25 } 26 27 }else { 28 break; 29 } 30 31 } 32 catch ( Exception e) { 33 e.printStackTrace(); 34 } 35 36 n++; 37 } 38 } 39} 40
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/04/07 12:04
2018/04/07 12:07
退会済みユーザー
2018/04/07 14:01