May I know how to find the largest number in an array?
Sunshineserene 0 Junior Poster
Recommended Answers
Jump to PostArrays.sort()
Jump to PostBecause Arrays.sort doesn't return anything. It sorts the array. After calling that simply take the last element of the array.
Jump to PostAs said a few posts ago ...
Object[] bogusArray = { /* some Objects */ }; Object someElement = bogusArray[bogusArray.length - 1];
Jump to PostWhere did the sort go?
And what "exception errors"?
Jump to PostWell don't assign the result of Arrays.sort to anything.
A "senior moment"? Arrays.sort sorts the array you pass to it and has return type null. Hence my concern that it changes the actual source data.
As for nth highest, median etc, I fully agree with you.
All 22 Replies
masijade 1,351 Industrious Poster Team Colleague Featured Poster
alexchen -12 Junior Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Sunshineserene 0 Junior Poster
aspire1 36 Light Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
sirlink99 56 Practically a Master Poster
Eric Cute 33 Posting Whiz in Training
Sunshineserene 0 Junior Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
Sunshineserene 0 Junior Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
Sunshineserene 0 Junior Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
Sunshineserene 0 Junior Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
masijade commented: I guess I deserved that. ;-) +10
masijade 1,351 Industrious Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Sunshineserene 0 Junior Poster
Sunshineserene 0 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.