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, "Такого сотрудника нет!");
}
}
我有兩個數組,其中包含整數和字符串。正如你所看到的,我想添加字符串數組中元素的個數(例如,wrkrs 3號)的int數組,稱爲wrkrs電話。我該怎麼做?我試過的IndexOf,但它不工作。Java中的Int和String數組
輸出,我想是這樣的:
Enter name:
Юра
That guy is at work!
Calling Юра + wrkrsPhone(Юра).
謝謝!我來試試!) –
Yeahh!這實際上是什麼,我需要) –