public class StringMassive { StringMassive helper = new StringMassive(); public static void main (String[] args) { //helper.receiver(String s); ошибка } public void massive() { String[] names = {"Антон", "Дмитрий", "Пётр"}; helper.receiver(names[0]); } public void receiver(String s) { System.out.println(s); } } Stuck on nonsense, please tell me. I have an array of names located in the massive() method. I select the zero element Anton from the array and pass it to the reciver(String s) method. How can I get the Anton element in the main method?
names[0]argument to therecivermethod. For a method to accept it, I must declare a parameter of this method of type String (the same as the passed argumentnames[0]). So I wroteString s. Can you do without it? - Kojer Defor