In an array first we have to find whether a desired number exists in that or not? If not then how will I find nearer number to the given desired number in Java?
Only thing missing is the semantics of closer.
What do you do if you're looking for six and your array has both four and eight?
Which one is closest?