Java Return Index Value If Value Found in Array

preview_player
Показать описание
Write A Program To Accept 10 Numbers In An Array Then Check And Display The Another Given Number Found Or Not, If Found Then Display With Its Position
Рекомендации по теме
Комментарии
Автор

Thank you for this tutorial. I am a little confuse how to display the index number of the number I want to search the the array.
For example, I input number 5 to search in the array, if number 5 is included in the array, it will give me the index number.
This is my code. Please check how can I make the output to be the index number. Thank you.

int number;

input = Search Number ");
number = Integer.parseInt(input);

number = no [0];

for (array = 0; array < loopCount; array++){

if (no[array] == number)
number = no [array];

}

JOptionPane.showMessageDialog (null, "index " + array, "Search",

System.exit(0);

nuvalinuvali
Автор

Thanks, but I was wondering why you have --1 at th end.

haroldbrown
Автор

mujh yay smj nai arha i-- ka kia kam horaha hai

sabedildar
visit shbcf.ru