Results 1 to 1 of 1
Thread: method efficiency
- 02-13-2008, 04:11 AM #1
Member
- Join Date
- Feb 2008
- Posts
- 1
- Rep Power
- 0
method efficiency
We got this method as homework assignment. There should be a way to make the method do less comparisons at runtime.
(the method finds the min and max of the array)
Any help would be appreciated.
Java Code:public void what() { int x = _arr[0]; int y = _arr[0]; for (int i=1; i<_arr.length; i++) { if (_arr[i] < x) x = _arr[i]; else if (_arr[i] > y) y = _arr[i]; } System.out.println (x + " " + y); }
Similar Threads
-
method not abstract, does not override actionperformed method.
By Theman in forum New To JavaReplies: 2Last Post: 03-26-2010, 05:12 PM -
Method Help
By pringle in forum New To JavaReplies: 4Last Post: 04-16-2008, 01:23 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks