迭代器给出NoSuchElementException

时间:2015-05-24 10:59:37

标签: java

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<title>ATM</title>
<body>
    <header>
        	<h1>Litman - Steklov ATMs</h1>

    </header>
    <section id="inventory">
        <form id="inventoryForm">
            <table>
                <thead>
                    <tr>
                        <th>Bill</th>
                        <th>Amount</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>20</td>
                        <td>
                            <input id="inventoryInput" class="inventoryInput" type="number">
                        </td>
                    </tr>
                    <tr>
                        <td>50</td>
                        <td>
                            <input id="inventoryInput2" class="inventoryInput" type="number">
                        </td>
                    </tr>
                    <tr>
                        <td>100</td>
                        <td>
                            <input id="inventoryInput3" class="inventoryInput" type="number">
                        </td>
                    </tr>
                    <tr>
                        <td>200</td>
                        <td>
                            <input id="inventoryInput4" class="inventoryInput" type="number">
                        </td>
                    </tr>
                </tbody>
            </table>
            <p id="inventoryError" class="error hidden">Validation errors will be here</p>
            <p>Total Money: <span id="totalMoney"></span> 
            </p>
            <button id="inventorySubmit" type="submit">Finish</button>
            <button id="inventoryChange" type="button" class="hidden">Change</button>
        </form>
    </section>
    <section id="withdraw" class="hidden">
        <form>
            <div>Withdraw:
                <input type="number">
            </div>
            <p class="error hidden">Validation errors will be here</p>
            <button type="submit">Process</button>
        </form>
    </section>
    <section id="result" class="hidden">
        <div>You Got:</div>
        <button type="button">Finish</button>
    </section>
</body>

</html>

由于某种原因,给我一个没有这样的元素例外。 当我用正常的for循环替换迭代器时,它完美地工作。但在某些情况下,我需要在迭代它们时编辑对象(在鼠标单击时),因此我需要一个迭代器但是没有工作......

2 个答案:

答案 0 :(得分:0)

每次调用i.next ()都会使迭代器前进。您应该只在循环内调用一次并将返回的值存储在变量中以便重用它,类似于您对j迭代器所做的操作。

答案 1 :(得分:0)

你在内循环中调用# Empty list for storing listData later. listData <- list() # Prepare SQL query1. dataQuery <- "SELECT * ...." # Store the result in data1. data1 = dbGetQuery(DB, dataQuery) if(nrow(data1) > 0) { # Append the data to the list. listData <- append(listData, data1) } # Merge data sets. set.seed(1) dataList = listData allData = Reduce(function(...) merge(..., all=T), dataList) 两次。你应该这样做:

next()