﻿ Java Collection, TreeSet Exercises: Get the element in a tree set which is greater than or equal to the given element - w3resource # Java Collection, TreeSet Exercises: Get the element in a tree set which is greater than or equal to the given element

## Java Collection, TreeSet Exercises: Exercise-10 with Solution

Write a Java program to get the element in a tree set which is greater than or equal to the given element.

Sample Solution:

Java Code:

``````import java.util.TreeSet;
import java.util.Iterator;

public class Exercise10 {
public static void main(String[] args) {
// creating TreeSet
TreeSet <Integer>tree_num = new TreeSet<Integer>();

// Add numbers in the tree

System.out.println("Greater than or equal to 86 : "+tree_num.ceiling(86));
System.out.println("Greater than or equal to 29 : "+tree_num.ceiling(29));
}
}
``````

Sample Output:

```Greater than or equal to 86 : 89
Greater than or equal to 29 : 36```

Flowchart: Java Code Editor:

What is the difficulty level of this exercise?

﻿

## Java: Tips of the Day

Choice between Float and Double:

Data type Bytes used Significant figures (decimal)
Float 4 7
Double 8 15

Double is often preferred over float in software where precision is important because of the following reasons:
Most processors take nearly the same amount of processing time to perform operations on Float and Double. Double offers far more precision in the same amount of computation time.

Ref: https://bit.ly/3oj7K2K