aspose file tools*
The moose likes Java in General and the fly likes swapping the elements in an array at the given index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "swapping the elements in an array at the given index" Watch "swapping the elements in an array at the given index" New topic
Author

swapping the elements in an array at the given index

Ambreen Khanam
Greenhorn

Joined: Apr 18, 2013
Posts: 4
Please provide me the best optimised solution for the below problem.

Say there is an array Array[1,2,3,4,5,6,7,8]. The elements needs to be swapped from index 0 to 4. The output should be somethin like this.

5,4,3,2,1,6,7,8
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
Welcome to the Ranch
We do not simply provide such solutions. I suggest you start with a method two swap two elements, in a utility classThen you use that method to swap however many elements you need to swap.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: swapping the elements in an array at the given index
 
Similar Threads
how to solve arrayindexoutofbound exception
Array elements
Multi column list box
[Solved] bubbleSorting + binary searching from methods .
How do you add objects to arrays?