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: Array Sorting - Asc, Desc

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Array Sorting - Asc, Desc

    Hi,
    I am soritng an array in ascending and descending order. I am using the nethods in Arrays as below

    Arrays.sort(myArray)

    I want to print both input and output array in sysout.

    Object[] ipArray = [45,8,32,41,11,7];
    Object[] opArray;
    Object mArray = ipArray;

    Arrays.sort(mArray); This is changing the ipArray too ?

    How can I get my input array unmodified ?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,765
    My Mood
    Mellow
    Thanks
    234
    Thanked 712 Times in 698 Posts

    Default Re: Array Sorting - Asc, Desc

    Review the difference between a shallow copy and a deep copy.

Similar Threads

  1. Array Sorting
    By keepStriving in forum Collections and Generics
    Replies: 4
    Last Post: November 18th, 2013, 05:35 PM
  2. [SOLVED] Java: Sorting int array in asc and desc
    By Abyd Ars in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 7th, 2013, 08:37 AM
  3. Array sorting
    By renars in forum Java Theory & Questions
    Replies: 4
    Last Post: May 17th, 2011, 10:45 AM
  4. [SOLVED] Sorting an Array
    By petemyster in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 12th, 2010, 10:07 AM
  5. Sorting an Array
    By Prince_85 in forum Algorithms & Recursion
    Replies: 2
    Last Post: February 21st, 2010, 02:00 PM