public class Kata {
public static String createPhoneNumber(int[] numbers) {
public int Int_to_str(int i) {
return Integer.toString(numbers[i]);
}
return "(" + Int_to_str(0) + Int_to_str(1) + Int_to_str(2) + ") " +
Int_to_str(3) + Int_to_str(4) + Int_to_str(5) + "-" +
Int_to_str(6) + Int_to_str(7) + Int_to_str(8) + Int_to_str(9);
}
}
Возвращает ошибку:
public int Int_to_str(int i){
^
/Kata.java:3: error: ';' expected
public int Int_to_str(int i){
^
/Kata.java:3: error: ';' expected
public int Int_to_str(int i){
У вас метод в методе. Вынесите его и сделайте static.
К примеру:
public class Kata {
private static int[] numbers = {1,2,3,4,5,6,7,8,9,0};
public static String createPhoneNumber(int[] numbers) {
return "(" + Int_to_str(0) + Int_to_str(1) + Int_to_str(2) + ") " +
Int_to_str(3) + Int_to_str(4) + Int_to_str(5) + "-" +
Int_to_str(6) + Int_to_str(7) + Int_to_str(8) + Int_to_str(9);
}
public static String Int_to_str(int i) {
return Integer.toString(numbers[i]);
}
public static void main(String args[]) {
System.out.println(createPhoneNumber(numbers));
}
}
Лишнее можно убрать оставить только методы. Код можно переписать намного лучше, но это тоже работает.
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости