Java tutorial
//package com.java2s; /******************************************************************************* * Copyright (c) 2008 Red Hat, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Elliott Baron <ebaron@redhat.com> - initial API and implementation *******************************************************************************/ public class Main { /** * Determines if argument is a number * @param string - argument to test * @return - true if argument is a number */ public static boolean isNumber(String string) { boolean result = true; char[] chars = string.toCharArray(); for (int i = 0; i < chars.length; i++) { if (!Character.isDigit(chars[i])) { result = false; } } return result; } }