a forloop inside a forloop - need help with logic

Posted on 2009-12-30
Last Modified: 2013-11-23
I have 2 arrays with size of 100. These arrays have elements inside them.

Lets say i have array1 and array2. I want something as follows ;

array1[1] then enters forloop and checks 1-50of array 2.
array1 goes to [2] and checks 1-50
and so on.

if i do just the basic a forloop inside a forloop for example ..

for(int i = 0; i<50; i++){
for(int i = 0; i<50; i++){

Would that work?
Question by:rinengan
    LVL 92

    Expert Comment

    for(int i = 0; i<50; i++){
    for(int j = 0; j<50; j++){
    LVL 6

    Expert Comment

    Yes, that would work - the inner loop would be repeated for each pass through the outer loop.
    LVL 40

    Accepted Solution

    i think he is looking for

    for(int i = 0; i<100; i++)
       for(int j = 0; j<50; j++)

    since he is looking for 50 elements only in the second array not the first one.


    Author Comment

    thanks alot guys, i just wanted 2 check with u if its alright :]

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Title # Comments Views Activity
    sameEnds challenge 25 55
    canBalance challenge 34 54
    array6 challenfge 6 48
    @SBGen Method 3 14
    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    This video teaches viewers about errors in exception handling.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now