Page 1 of 1

About Question enthuware.ocpjp.v7.2.1280 :

Posted: Wed Aug 27, 2014 11:24 am
by shareef.hiasat
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.

Re: About Question enthuware.ocpjp.v7.2.1280 :

Posted: Wed Aug 27, 2014 7:41 pm
by admin
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

Re: About Question enthuware.ocpjp.v7.2.1280 :

Posted: Sat Sep 13, 2014 9:14 am
by shareef.hiasat
admin 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
ok but what is the rule here in this example please

Image
Image
http://s14.postimg.org/6t1xswti9/cielling.jpg

Re: About Question enthuware.ocpjp.v7.2.1280 :

Posted: Sat Sep 13, 2014 11:02 am
by admin
I am sorry I didn't understand your question. Rule is same for this question. Higher and ceiling are different methods and work differently.

Re: About Question enthuware.ocpjp.v7.2.1280 :

Posted: Thu Jan 08, 2015 10:49 am
by Svetopolk
"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

Re: About Question enthuware.ocpjp.v7.2.1280 :

Posted: Wed Jun 21, 2023 3:26 pm
by dmullandev2
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")?

Re: About Question enthuware.ocpjp.v7.2.1280 :

Posted: Wed Jun 21, 2023 8:24 pm
by admin
>>how is aa higher than higher("a")?

Not sure what you mean. Can you please clarify your question?