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: .add(j, i); not updating array

  1. #1
    Member Scotty's Avatar
    Join Date
    Oct 2010
    Posts
    60
    My Mood
    Scared
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default .add(j, i); not updating array

    The code below works, but index.add(j, i) does not update when highest does? I need to know which ones in the array were selected to be the highest. I have also tried using a variable and using (array.add(index)), near array.add(highest); is, but it always says 0. array does contain the correct highest values, so highest = array.get(i); must work?

    Also print statements do not work near highest = array.get(i);?

     
    for (int j =0; j<7; j++) {
    		index.add(j, 0);
    	int highest = array.get(j*7+1);
    	for (int i = 2+(j*7); i<7+(j*7)+1;i = i+7+1) {
    		if highest<array.get(i)) {
    			index.add(j, i);
    			highest = array.get(i);
     
    		}
    	}
    array.add(highest);
    	}

    Thanks


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: .add(j, i); not updating array

    If you want help, you should provide an SSCCE that demonstrates what you're trying to do. Looking at the code you provided, we can't really tell what's going on. What is index? What is the input? What's the output?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Need Help on Updating a GUI Java
    By coyboss in forum Object Oriented Programming
    Replies: 9
    Last Post: March 6th, 2011, 10:00 PM
  2. Updating timer
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 10
    Last Post: January 26th, 2011, 07:02 AM
  3. Updating GUI dynamically
    By KrisTheSavage in forum AWT / Java Swing
    Replies: 2
    Last Post: August 29th, 2010, 08:23 AM
  4. MouseMotionListener is not updating my variable
    By olemagro in forum AWT / Java Swing
    Replies: 1
    Last Post: February 8th, 2010, 03:44 PM
  5. updating database
    By gurpreetm13 in forum JDBC & Databases
    Replies: 3
    Last Post: October 9th, 2009, 11:43 AM