This Java program defines a class named Strictly_Greater which contains a main method that creates a TreeSet of integers and adds some elements to it. The program then calls the higher method on the TreeSet with an argument of 55, which returns the smallest element in the set that is strictly greater than 55. This value is then printed to the console using the println method.
In this particular case, the TreeSet contains the elements {20, 30, 50, 60, 70}. The smallest element in the set that is strictly greater than 55 is 60, so the program outputs:
import java.io.*; import java.util.*; public class Strictly_Greater { public static void main(String args[]) { TreeSet <Integer> num = new TreeSet <Integer>(); num.add(70); num.add(30); num.add(50); num.add(20); num.add(60); int higher = num.higher(55); System.out.println("Strictly Higher Element : " + higher); } }
Strictly Higher Element : 60
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions