Понимаю, что примеры из условия не проходят. Не понимаю, почему. Подскажите, пожалуйста, что упустила?
package com.javarush.task.task22.task2212;
/*
Проверка номера телефона
*/
public class Solution {
public static boolean checkTelNumber(String telNumber) {
if (telNumber.matches("\\d$") && telNumber.matches("\\d | \\+ |\\(\\)")) {
if (telNumber.matches("^\\+") && telNumber.matches("[0-9]{12}")
|| (telNumber.matches("^\\d | \\^\\(")) && telNumber.matches("[0-9]{10}")) {
if (!(telNumber.matches("\\(\\)"))) {
return true;
} else {
return telNumber.matches("\\b\\(\\d{3}\\)");
}
} else {
return false;
}
}
return false;
}
public static void main(String[] args) {
}
}