Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Problems with for loop

  1. #1
    Junior Member
    Join Date
    Aug 2020
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Red face Problems with for loop

    Hello,
    I want to write a function which counts amount of recursive calls depending on of amount of elements that are already in redBlackTree.


    But when I try to do this using for loop so I can give any amonut of values results aren't right.

    I tested it for Strings also. What might be the problem? Thank you for your answers.
    Last edited by javastart; November 1st, 2020 at 12:30 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problems with for loop

    results aren't right.
    Please explain. Show the results from the current program and also give the correct results.

    How can the code be compiled and executed for testing?
                    numberOfElems++;
                    result[numberOfElems-1] = redBlackTree.getCount();
    Why add one and then subtract one? Why not swap those two statements?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. problems with loop
    By hashirama in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 4th, 2013, 04:45 PM
  2. problems with loop
    By hashirama in forum Member Introductions
    Replies: 5
    Last Post: October 4th, 2013, 04:45 PM
  3. problems with for loop
    By sorbazz in forum Loops & Control Statements
    Replies: 7
    Last Post: December 6th, 2012, 07:48 AM
  4. [SOLVED] Problems with Loop Structure
    By Sean137 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: December 13th, 2010, 02:59 PM
  5. problems with loop in Java App
    By dmonx in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 13th, 2010, 04:13 PM

Tags for this Thread