Maximum element of Set
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) {
Set<Long> hashSet = new HashSet<Long>();
hashSet.add(new Long("1111111111"));
hashSet.add(new Long("2222222222"));
hashSet.add(new Long("3333333333"));
hashSet.add(new Long("4444444444"));
hashSet.add(new Long("5555555555"));
Object obj = Collections.max(hashSet);
System.out.println(obj);
}
}
Output:
5555555555
Home
Java Book
Runnable examples
Java Book
Runnable examples
Collection Set:
- Convert set to an Array
- Convert Set into List
- Convert a set to a synchronized Set
- Is a particular value in(exist) Set
- Iterator a set
- Maximum element of Set
- Minimum element of a Set
- Remove all elements from a set
- Remove element from Set
- Remove one set from another set
- Remove all the elements from one set to another set
- Union(Add) all the elements from one set to another set
- Intersection of one set and another set
- Set operations: union, intersection, difference
- Set operations: symmetric difference, is subset, is superset
- Size of a Set