forループ内でarraylistの値を比較しているメソッドがあります。Loop 2
loop1 に対して 1 つの条件が true の場合、(以下のコードを参照) を実行したくありません。
さて、ハッピングとは、いくつかの値loop 1
はstatisfyであり、他のいくつ かの値は満足しloop 2
ています.だから、これのせいで、私はdbが間違ったデータを入力しています.
そのような方法でコードを変更したいと思います。配列リストの値のいずれかが満足しているloop 1
場合、コンパイラは から戻る必要がありreturn ERROR
ます。その後、コードを実行しないでください。
ループチェック条件はif(quant>Integer.parseInt(book.getQuantity()))
Action.java.
public String execute()
{
if(id.length == quantity.length)
{
for (int i = 0; i < id.length; ++i)
{
book = dao.listbookdetailsByBId(id[i]);
Double dq=new Double(quantity[i]);
int quant=dq.intValue();
if(quant>Integer.parseInt(book.getQuantity()))
{
//Loop 1 , this is executing if any of the quant is greater then book.getQuantity()..
//i want to stop executing LOOP2 ,if any of the value of quant is greater then book.getQuantity().
addActionError("You have entered an invalid quantity for the Book Title- ''"+book.getBookTitile()+"''.");
return ERROR;
}
/* Loop2 starts here
* Loop 2 , this is executing if any of the quant is lesser ..
* The below code should execute only if compiler does not reach to the loop1 */
// Some DAO code goes here
}
}
return SUCCESS;
}