About Question enthuware.ocpjp.v7.2.1280 :
Moderator: admin
-
- Posts: 20
- Joined: Thu Dec 19, 2013 8:22 am
- Contact:
About Question enthuware.ocpjp.v7.2.1280 :
This cant convince me i think the ceiling and higher is the same ,,.. or what
aaa --> higher b as question
so isnt
aaa --> ceiling b too but in the question its not
why
bb --> higher c as question
so isnt
bb -->ceiling is c too ?
E ceiling(E e)
Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
E floor(E e)
Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
E higher(E e)
Returns the least element in this set strictly greater than the given element, or null if there is no such element.
E lower(E e)
Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
Note that methods of NavigableMap (such as ceilingEntry(), ceilingKey(), floorEntry(), floorKey() etc.) also work exactly the same way.
aaa --> higher b as question
so isnt
aaa --> ceiling b too but in the question its not
why
bb --> higher c as question
so isnt
bb -->ceiling is c too ?
E ceiling(E e)
Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
E floor(E e)
Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
E higher(E e)
Returns the least element in this set strictly greater than the given element, or null if there is no such element.
E lower(E e)
Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
Note that methods of NavigableMap (such as ceilingEntry(), ceilingKey(), floorEntry(), floorKey() etc.) also work exactly the same way.
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1280 :
ceiling and higher are not same. Kindly read their descriptions. In some cases, they may return same values but not in all.
System.out.println(ns.higher("bb")); //prints c
System.out.println(ns.ceiling("bb")); //prints bb
System.out.println(ns.higher("bb")); //prints c
System.out.println(ns.ceiling("bb")); //prints bb
-
- Posts: 20
- Joined: Thu Dec 19, 2013 8:22 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1280 :
ok but what is the rule here in this example pleaseadmin wrote:ceiling and higher are not same. Kindly read their descriptions. In some cases, they may return same values but not in all.
System.out.println(ns.higher("bb")); //prints c
System.out.println(ns.ceiling("bb")); //prints bb

http://s14.postimg.org/6t1xswti9/cielling.jpg
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1280 :
I am sorry I didn't understand your question. Rule is same for this question. Higher and ceiling are different methods and work differently.
-
- Posts: 22
- Joined: Sun Nov 18, 2012 1:51 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1280 :
"Returns the least element in this set greater than ... " - the explanation is formally correct but from the other hand it seems it is made to confuse.
I offer followed just to easy remembering:
higher - higher (greater)
ceiling - higher or equal
lower - lower (smaller)
floor - lower or equal
I offer followed just to easy remembering:
higher - higher (greater)
ceiling - higher or equal
lower - lower (smaller)
floor - lower or equal
-
- Posts: 2
- Joined: Fri Apr 28, 2023 6:45 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1280 :
NavigableSet<String> myStringSet = new TreeSet<String>();
myStringSet.add("a");
myStringSet.add("aa");
myStringSet.add("b");
myStringSet.add("bb");
myStringSet.add("c");
myStringSet.add("cc");
System.out.println();
System.out.println(myStringSet);
System.out.println("TreeSet.ceiling(): " + myStringSet.ceiling("a"));
System.out.println("TreeSet.higher(): " + myStringSet.higher("a"));
Output:
[a, aa, b, bb, c, cc]
TreeSet.ceiling(): a
TreeSet.higher(): aa
doesn't seem right to me? how is aa higher than higher("a")?
myStringSet.add("a");
myStringSet.add("aa");
myStringSet.add("b");
myStringSet.add("bb");
myStringSet.add("c");
myStringSet.add("cc");
System.out.println();
System.out.println(myStringSet);
System.out.println("TreeSet.ceiling(): " + myStringSet.ceiling("a"));
System.out.println("TreeSet.higher(): " + myStringSet.higher("a"));
Output:
[a, aa, b, bb, c, cc]
TreeSet.ceiling(): a
TreeSet.higher(): aa
doesn't seem right to me? how is aa higher than higher("a")?
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1280 :
>>how is aa higher than higher("a")?
Not sure what you mean. Can you please clarify your question?
Not sure what you mean. Can you please clarify your question?
Who is online
Users browsing this forum: No registered users and 9 guests