See here for documentation of those two methods.
It's easier to explain for Numbers then for String as String internally will use compareTo method, unless you pass custom Comparator to constructor of treeset. Consider this code:
TreeSet<Integer> set = new TreeSet<Integer>();
set.add(1);
set.add(2);
set.add(3);
set.add(4);
set.add(5);
Cieling says
Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
So if i want to search for 10, i dont see any element greater than 10 and hence it will return me null. Wile if i want to search for 0, the next greater element is 1, so it will return 1. While if i give 4, then i have exact match so it will return 4.
While floor says:
Returns the greatest element in this set less than or equal to the given element, or null if there is no such element
So if i want to search for 0, i dont see any element less than 0 in the entire set and hence it will return me null. Wile if i want to search for 10, the next lesser element is 5, so it will return 5. While if i give 4, then i have exact match so it will return 4.
For String it will internally call compareTo method and compare two string lexicographically and the behavior would be same as what is for integer.