• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 868
  • Last Modified:

Java find max element in Vector

Hi everybody
I have v = Vector<Double> and I need to check if a certain given index corresponds to the maximum element in the Vector. In other words, I need to check if
v.get(index) == Collections.max(v)
Obviously the line above doesn't compile since I am comparing a Double and a Object...
0
perissf
Asked:
perissf
  • 2
1 Solution
 
CEHJCommented:
>>v.get(index) == Collections.max(v)

Try instead
v.get(index).equals(Collections.max(v))

Open in new window

0
 
perissfAuthor Commented:
wow!!
0
 
CEHJCommented:
:-)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now