Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static boolean validatePhone(String phone) { try { if (phone.trim().length() == 0) { return false; } double n = Double.parseDouble(phone); if (!(phone.trim().toString().startsWith("7") || phone.trim().toString().startsWith("8") || phone.trim().toString().startsWith("9"))) return false; if (phone.trim().length() == 10) return true; } catch (Exception e) { return false; } return false; } }