I am new with Java and also new user of this website, this is my array
double array[] = new double[6];
// Initializing elements
array[0] = 0.334;
array[1] = 0.334;
array[2] = 0.334;
array[3] = 0.501;
array[4] = 0.501;
array[5] = 0.334;
// Use for loop to display elements
for (int i = 0; i < array.length; i++)
{
System.out.print(array[i]);
System.out.print("\n");
}
I want to find out all indices for the value (0.334); I mean for this example it should return 4, which shows that 4 indices have this value.
int index=-1;
int i;
for(i = 0; i < array.length;i++)
{
if (Input>=array[i]== ) // user input = 0.334
{
index=array[i];
System.out.print("Output = "+index);
return ;
}
}