vendredi 31 juillet 2015

For Each Loop in Java: IndexOutOfRangeException

Why does the following code gives IndexOutOfRangeException in Java:

    Dim intNum() As Integer = {1, 2, 3, 4, 5}
    Dim tot As Integer
    For Each n As Integer In intNum
        tot = tot + intNum(n)
    Next
    MsgBox(tot)

Aucun commentaire:

Enregistrer un commentaire