This is my solution use JAVA.

```
public static int searchInsert( int[] nums, int target ){
int low = 0, high = nums.length - 1;
int middle = 0;
while( low <= high ){
middle = ( low + high ) / 2;
if( nums[middle] < target )
low = middle + 1;
else if( nums[middle] > target )
high = middle - 1;
else
break;
}
if( low > high ) return low;
else return middle;
}
```