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: Need help finishing code. List Building...

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help finishing code. List Building...

    I need to build a list and then return the Min and Max number, The code I have just keeps returning 0s. Could any one help? Thnx

    private SimpleList<Integer> buildList(String line) {
    //Build a list of integers from line
    //Assume the line is syntactically correct
    SimpleList <Integer> list;
    list = new SimpleList <Integer>();

    int i = 0;

    while (i<line.length()){

    list.add(i);
    i++;
    }
    return list;
    }

    private int findMax(SimpleList<Integer> list) {
    //Return the maximum integer in list
    list.reset();

    int Max = list.next();

    while (list.hasNext()){
    int t = list.next();
    if(t > (Max));
    t = Max;
    }
    return Max;

    }

    private int findMin(SimpleList<Integer> list) {
    //Return the minimum integer in list
    list.reset();

    int min = list.next();

    while (list.hasNext()){
    int x = list.next();
    if(x < (min));
    x = min;
    }
    return min;
    }


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Need help finishing code. List Building...

    http://www.javaprogrammingforums.com...g-min-max.html

    Duplicate post.
    Improving the world one idiot at a time!

Similar Threads

  1. Need help building a simple calculator
    By zigma in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 14th, 2011, 01:13 AM
  2. Beginner. Need Help finishing a simple Shoot em up game ASAP!!!!
    By cbock55 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 2nd, 2011, 08:13 AM
  3. help building up GUI for poker game
    By Pencil in forum AWT / Java Swing
    Replies: 5
    Last Post: October 26th, 2010, 02:53 PM
  4. Pseudo code of insertion sort linked list
    By sungirl in forum Algorithms & Recursion
    Replies: 1
    Last Post: May 23rd, 2010, 09:25 AM
  5. Building a Menu List
    By websey in forum AWT / Java Swing
    Replies: 1
    Last Post: November 15th, 2009, 10:34 AM

Tags for this Thread