Java tutorial
//package com.java2s; public class Main { public static boolean isJustDigitStar1(String str) { int len = 0; for (int idx = 0; idx < str.length(); idx++) { if (Character.isDigit(str.charAt(idx)) || str.charAt(idx) == '*' || str.charAt(idx) == '-') { len++; } } if (len == str.length()) { return true; } return false; } }