Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * test for numbers in a given string
     *
     * @param String text - text for searching
     * @return boolean - true: text contains numbers, false: text not contains numbers
     */
    public static boolean containsNumbers(String text) {
        for (int i = 0; i < text.length(); i++) {
            if (((int) text.charAt(i) >= 48) && ((int) text.charAt(i) <= 57)) {
                return true;
            }
        }
        return false;
    }
}