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 3 of 3

Thread: Substitution of Values in Array

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

    Default Substitution of Values in Array

    How do I substitute a value x (wherever it occurs in an array) with a value y???

    Thanks in advance,
    nyeung


  2. #2
    Member
    Join Date
    Oct 2009
    Posts
    52
    Thanks
    0
    Thanked 6 Times in 5 Posts

    Default Re: Substitution of Values in Array

    You need to loop through the array and check each value. If the value is of x, then change that value to y.

    Here is some pseudo code:

    a = new array()
    for (each element in a) {
        if (element equals x) {
            y is assigned to element
        }
    }
    Last edited by literallyjer; October 26th, 2009 at 06:49 PM.

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Substitution of Values in Array

    Thanks! I really appreciate your help and support!

    Sincerely,
    nyeung

Similar Threads

  1. Replies: 1
    Last Post: December 22nd, 2011, 09:55 AM
  2. Values of Input
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 8th, 2009, 03:46 AM
  3. Having trouble insert/sorting array values w/ binary searching.
    By bh-chobo in forum Collections and Generics
    Replies: 4
    Last Post: October 8th, 2009, 02:38 AM
  4. How to share variable values amongst different classes?
    By igniteflow in forum Object Oriented Programming
    Replies: 8
    Last Post: August 20th, 2009, 08:53 AM
  5. Reading IEEE float values from files.
    By username9000 in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: June 30th, 2009, 12:56 PM