Win a copy of Java by Comparison (eBook) this week in the Java in General forum!

Vinod kashid

Greenhorn
+ Follow
since Oct 18, 2013
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vinod kashid

Jeanne Boyarsky wrote:Where did you buy it from? I paid online for my exam with Prometric directly.



I buy voucher from niit
In how many days i will get my ocjp voucher after purchase.

Henry Wong wrote:

Vinod kashid wrote:i have problem with following code
String[] arr = {"java", "champ", "you"};
System.out.print(Arrays.binarySearch(arr, "java"));
System.out.print(Arrays.binarySearch(arr, "You"));

please explain output of above code.



Since the binarySearch() method requires that the array be sorted -- doing a search on an unsorted array, may or may not work.... so, are you saying that it works in some cases, and doesn't in others?

Henry



when i run this code i got output as -3 -1.
but when String[] arr = {"you", "champ", "java"}; output is 2 -1.
here arr[] is also unsorted .
i have problem with following code
String[] arr = {"java", "champ", "you"};
System.out.print(Arrays.binarySearch(arr, "java"));
System.out.print(Arrays.binarySearch(arr, "You"));

please explain output of above code.