Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript What is the use of i+1 here? It’s java not javascript…

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #39619
    samnizamani
    Member
    class Test{
    public static void main(String args[]) {
    int twoD[][] = new int[5][];
    twoD[0] = new int[1];
    twoD[1] = new int[2];
    twoD[2] = new int[3];
    twoD[3] = new int[4];
    twoD[4] = new int[5];
    int i, j, k = 0;
    for(i=0; i<5; i++)
    for(j=0; j twoD[j] = k;
    k++;
    }
    for(i=0; i<5; i++) {
    for(j=0; j System.out.print(twoD
    [j] + " ");
    System.out.println();
    }


    }
    }
    #108912
    samnizamani
    Member

    @BenWalker, U r ryt, i have copied this code from java refernce book by herbert schildt, Yeah the code seems a bit random, Coz for one statement he doesn’t use curly braces in the for loop… Thx Both Of U guys for your sweet replies… PEACE

    #108914
    samnizamani
    Member

    @Benwalker U r ryt, I willl use that technique now, he has also used the same technique that u showed me in your example, I dnt know why he confused me with i+1…

    #108916
    samnizamani
    Member

    @BenWalker I have compiled your code, but it has a problem, It comes in a staight line, Like this,
    0
    1
    2
    3
    4
    5
    BUt code that i showed u, with i+1 comes out to be this,
    0
    1 2
    3 4 5
    6 7 8 9

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.