This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Revere elements Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Revere elements" Watch "Revere elements" New topic
Author

Revere elements

Amit Chohan
Greenhorn

Joined: Oct 31, 2002
Posts: 29
hi all
the following code reverses elements in an array. Is there a more efficient way of writing it.

thanks
Amit Chohan


Java Junior<br />Leicester<br />England
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1865
hi amit,
it seems the method u use is fine in int[] case.
here is the code i tired,

and a script to generate multiple results to get average,

the average was,
Reverse-1: 275.65
Reverse-2: 747.40
Reverse-3: 474.40
Reverse-4: 808.24
Reverse-5: 802.33

may be if we post this to Performance forum it would get more responses...
regards
maulin.


1. Have fun @ http://faq.javaranch.com/java/JavaRaq
2. Looking for simple infix2postfix conversion and postfix evaluation package? Click here
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1865
btw,
the average is in milliseconds to perform reverse operation...
thanks
maulin
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Revere elements
 
Similar Threads
Can I pass an array of ints to a class?
New ArrayList Problem
Accessing servlet-config parameter through EL
array
Error! Array Index Out Of Bounds Exception