Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

check if string has a valid number java

private boolean isInt(String s){
        try{
            Integer.parseInt(s);
            return true;
        }catch (NumberFormatException e){
            return false;
        }
    }
Comment

java string contains number

str.matches(".*d.*");
Comment

java program to Check given String is contians number or not

public class ContainsExample {
   public static void main(String args[]){
      String sample = "krishna64";
      char[] chars = sample.toCharArray();
      StringBuilder sb = new StringBuilder();
      for(char c : chars){
         if(Character.isDigit(c)){
            sb.append(c);
         }
      }
      System.out.println(sb);
   }
Comment

PREVIOUS NEXT
Code Example
Java :: JsonArray get first Object 
Java :: logging in java 
Java :: java variable declaration 
Java :: set text from strings.xml 
Java :: basic java programs 
Java :: multiple condition inside for loop java 
Java :: find last element in array in java 
Java :: convert java to python 
Java :: button getsource 
Java :: infinite for loop java example 
Java :: java how to create an array 
Java :: elif java 
Java :: java question mark operator 
Java :: how to convert line into string java 
Java :: smart ways to print a matrix in java 
Java :: java all characters in alphabet order simpler 
Java :: How to read and write XML files 
Java :: java get size of array 
Java :: why enable multidex android 
Java :: prime numbers program in java 
Java :: loop array using stream java 
Java :: java create arraylist with size 
Java :: Java String equal String 
Java :: better way to check string on null and empty java 
Java :: jdbc dependency 
Java :: java print boolean with spaces 
Java :: What is the function of an IntentFilter? 
Java :: java Math.sqrt(double) 
Java :: scanf in java 
Java :: how to remove scroll pane border 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =