public class CHECK {
public CHECK(){
String []wrkrs = {"Денис", "Саша", "Наталья", "Анатолий", "Юра", "Коля", "Катя", "Дима", "Антон","Тамара"};
int [] wrkrsPhone = {22626,22627,22628,22629,22630,22631,22632,22633,22634,22635};
String a = JOptionPane.showInputDialog(null, "Hello,friend!Do you wanna know, is that guy at work?Enter name:");
if(Arrays.asList(wrkrs).contains(a)){
JOptionPane.showMessageDialog(null, "That guy is at work!");
JOptionPane.showMessageDialog(null, "calling " + wrkrsPhone[wrkrsPhone.toString().indexOf(a)]);
}else{
JOptionPane.showMessageDialog(null, "Такого сотрудника нет!");
}
}
I have two arrays, which contain ints and strings. As you can see, I want to add the number of elements in the string array (for example, wrkrs number 3) to the int array, called wrkrs phone. How can i do it? I tried IndexOf, but it doesn't work.
The output, i want is something like:
Enter name:
Юра
That guy is at work!
Calling Юра + wrkrsPhone(Юра).