File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections - Insertion Point Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collections - Insertion Point" Watch "Collections - Insertion Point" New topic

Collections - Insertion Point

Venkat Sidh
Ranch Hand

Joined: Sep 30, 2006
Posts: 61
From K & B,

Since 0 is a valid
result for a successful search, the first available insertion point is -1. Therefore,
the actual insertion point is represented as (-(insertion point) -1). For
instance, if the insertion point of a search is at element 2, the actual insertion
point returned will be -3.

does it mean to say if I'm searching for String "c" in the following array

insertion point would be 2 since "c" is not present in array and the actual insertion point returned will be -3. Is it correct. Thanks.
Anderson Souza

Joined: Oct 12, 2006
Posts: 3

You are absolutely right.

Venkat Sidh
Ranch Hand

Joined: Sep 30, 2006
Posts: 61

What's difference between insertion point and actual insertion point and where are they used.

subject: Collections - Insertion Point
Similar Threads
K & B book p. 659 - Explanation to self test question 16
Question regarding binarySearch....
Doubt in binarySearch
Confusion in understanding Comparator in Java