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: How do you edit an array?

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default How do you edit an array?

     
    import java.util.Random;
     
     
    public class Basic{
     
    	public static void main(String[] args) {
    		System.out.printf("The values in the array are:\n");
     
    		Random randomNumbers = new Random();
    		int[] array = new int[ 5 ];
     
    		for (int num = 0; num <array.length; num++ )
    			array[num] = randomNumbers.nextInt(50);
     
    		for (int value = 0; value < array.length; value++ )
    			System.out.printf("value[ %2d ] =%4d\n", value, array[ value ]);
     
     
    		}
    	}

    My program displays 5 random numbers. I want the user to be able to pick one of those numbers and be able to change it to any number they want. I have absolutely no idea how to even begin. Any help would be appreciated, this array stuff is hard to learn for me.


  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: How do you edit an array?

    You edit an array exactly how you initialize an array. array[index] = whatever.

    Recommended reading: http://www.javaprogrammingforums.com...e-posting.html
    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!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    alkamenes (October 13th, 2011)

Similar Threads

  1. DJWebrowser Edit problem
    By Jhovarie in forum AWT / Java Swing
    Replies: 2
    Last Post: June 15th, 2011, 07:42 PM
  2. JFrame Edit
    By n00b123 in forum AWT / Java Swing
    Replies: 1
    Last Post: May 19th, 2010, 08:23 PM
  3. Loading Images and Edit it
    By shadihrr in forum Java Theory & Questions
    Replies: 1
    Last Post: March 25th, 2010, 08:39 PM
  4. Edit ArrayList Object
    By frankycool in forum Collections and Generics
    Replies: 12
    Last Post: November 16th, 2009, 12:31 AM
  5. Struts combobox edit
    By kalees in forum Web Frameworks
    Replies: 2
    Last Post: November 1st, 2009, 12:27 AM