FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b141)
Java hotSpot(TM) Client VM (build 21.0-b11, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 Ultimate 32-bit (6.1.7601, Service Pack 1, Build 7601
A DESCRIPTION OF THE PROBLEM :
I want find max element of array. To do this, I run the following code:
import java.util.Arrays;
public class Main {
public Main() {
}
private int indexOfMax(double [] srcArray) {
double [] d = srcArray.clone();
double [] d1 = d.clone();
Arrays.sort(d);
return Arrays.binarySearch(d1, d[d.length - 1]);
}
public static void main(String [] arg) {
double [] temp = new double[10];
temp[0] = 0.4815744900320782;
temp[1] = 0.9853950553753187;
temp[2] = 0.020195572196603062;
temp[3] = 0.4974630862907763;
temp[4] = 0.5874958585228355;
temp[5] = 0.635202254872451;
temp[6] = 0.7153486493049164;
temp[7] = 0.42789599708037096;
temp[8] = 0.7125307280379825;
temp[9] = 0.7928702536478623;
Main m = new Main();
System.out.println(m.indexOfMax(temp));
}
}
But the resulting value is "-11".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create project "Java Application". Head Class must have name is "Main.java". Next run code:
import java.util.Arrays;
public class Main {
public Main() {
}
private int indexOfMax(double [] srcArray) {
double [] d = srcArray.clone();
double [] d1 = d.clone();
Arrays.sort(d);
return Arrays.binarySearch(d1, d[d.length - 1]);
}
public static void main(String [] arg) {
double [] temp = new double[10];
temp[0] = 0.4815744900320782;
temp[1] = 0.9853950553753187;
temp[2] = 0.020195572196603062;
temp[3] = 0.4974630862907763;
temp[4] = 0.5874958585228355;
temp[5] = 0.635202254872451;
temp[6] = 0.7153486493049164;
temp[7] = 0.42789599708037096;
temp[8] = 0.7125307280379825;
temp[9] = 0.7928702536478623;
Main m = new Main();
System.out.println(m.indexOfMax(temp));
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
resulting value must equal is "1"
ACTUAL -
i was get resulting value is "-11"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Arrays;
public class Main {
public Main() {
}
private int indexOfMax(double [] srcArray) {
double [] d = srcArray.clone();
double [] d1 = d.clone();
Arrays.sort(d);
return Arrays.binarySearch(d1, d[d.length - 1]);
}
public static void main(String [] arg) {
double [] temp = new double[10];
temp[0] = 0.4815744900320782;
temp[1] = 0.9853950553753187;
temp[2] = 0.020195572196603062;
temp[3] = 0.4974630862907763;
temp[4] = 0.5874958585228355;
temp[5] = 0.635202254872451;
temp[6] = 0.7153486493049164;
temp[7] = 0.42789599708037096;
temp[8] = 0.7125307280379825;
temp[9] = 0.7928702536478623;
Main m = new Main();
System.out.println(m.indexOfMax(temp));
}
}
---------- END SOURCE ----------
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b141)
Java hotSpot(TM) Client VM (build 21.0-b11, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 Ultimate 32-bit (6.1.7601, Service Pack 1, Build 7601
A DESCRIPTION OF THE PROBLEM :
I want find max element of array. To do this, I run the following code:
import java.util.Arrays;
public class Main {
public Main() {
}
private int indexOfMax(double [] srcArray) {
double [] d = srcArray.clone();
double [] d1 = d.clone();
Arrays.sort(d);
return Arrays.binarySearch(d1, d[d.length - 1]);
}
public static void main(String [] arg) {
double [] temp = new double[10];
temp[0] = 0.4815744900320782;
temp[1] = 0.9853950553753187;
temp[2] = 0.020195572196603062;
temp[3] = 0.4974630862907763;
temp[4] = 0.5874958585228355;
temp[5] = 0.635202254872451;
temp[6] = 0.7153486493049164;
temp[7] = 0.42789599708037096;
temp[8] = 0.7125307280379825;
temp[9] = 0.7928702536478623;
Main m = new Main();
System.out.println(m.indexOfMax(temp));
}
}
But the resulting value is "-11".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create project "Java Application". Head Class must have name is "Main.java". Next run code:
import java.util.Arrays;
public class Main {
public Main() {
}
private int indexOfMax(double [] srcArray) {
double [] d = srcArray.clone();
double [] d1 = d.clone();
Arrays.sort(d);
return Arrays.binarySearch(d1, d[d.length - 1]);
}
public static void main(String [] arg) {
double [] temp = new double[10];
temp[0] = 0.4815744900320782;
temp[1] = 0.9853950553753187;
temp[2] = 0.020195572196603062;
temp[3] = 0.4974630862907763;
temp[4] = 0.5874958585228355;
temp[5] = 0.635202254872451;
temp[6] = 0.7153486493049164;
temp[7] = 0.42789599708037096;
temp[8] = 0.7125307280379825;
temp[9] = 0.7928702536478623;
Main m = new Main();
System.out.println(m.indexOfMax(temp));
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
resulting value must equal is "1"
ACTUAL -
i was get resulting value is "-11"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Arrays;
public class Main {
public Main() {
}
private int indexOfMax(double [] srcArray) {
double [] d = srcArray.clone();
double [] d1 = d.clone();
Arrays.sort(d);
return Arrays.binarySearch(d1, d[d.length - 1]);
}
public static void main(String [] arg) {
double [] temp = new double[10];
temp[0] = 0.4815744900320782;
temp[1] = 0.9853950553753187;
temp[2] = 0.020195572196603062;
temp[3] = 0.4974630862907763;
temp[4] = 0.5874958585228355;
temp[5] = 0.635202254872451;
temp[6] = 0.7153486493049164;
temp[7] = 0.42789599708037096;
temp[8] = 0.7125307280379825;
temp[9] = 0.7928702536478623;
Main m = new Main();
System.out.println(m.indexOfMax(temp));
}
}
---------- END SOURCE ----------