Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java get number out of string

for(int i=0; i<yourString.length();i++) {
  if(Character.isDigit(yourString.charAt(i))) {
    // Do something with the number
    // For example convert it to int:
    int yourNumber = Integer.parseInt(String.valueOf(yourString.charAt(i)));
  }
}
Comment

java get number at the end of string

public static BigInteger lastBigInteger(String s) {
    int i = s.length();
    while (i > 0 && Character.isDigit(s.charAt(i - 1))) {
        i--;
    }
    return new BigInteger(s.substring(i));
}
Comment

PREVIOUS NEXT
Code Example
Java :: log messages not printing in springboot using org.slf4j.Logger; 
Java :: Android listen to network change 
Java :: click on recyclerview item android animation 
Java :: string compareto vs equals java 
Java :: java wrapper classes 
Java :: is c# similar to java 
Java :: firebase realtime database get key 
Java :: 2-dimensional Array java 
Java :: processing pi 
Java :: How to change integers into float in java 
Java :: java.lang.classcastexception: java.lang.string cannot be cast to java.util.arraylist 
Java :: lambda function java 
Java :: java record 
Java :: android studio checkbox result 
Java :: remove duplicates from arraylist in android 
Java :: java array quick sort 
Java :: round to the next multiple of 5 
Java :: constructor of class that extends another class 
Java :: comments java 
Java :: convert java code to kotlin online converter 
Java :: stringbuilder example in java 
Java :: convert character arraylist to array 
Java :: method overriding in java 
Java :: string cannot be resolved to a type eclipse 
Java :: spring mongodb 
Java :: Map - counting with map 
Java :: intellij java fx new window 
Java :: HOW TO MAKE ENUM START WITH ONE 
Java :: access db in fragments 
Java :: how to pass parameters to xsl file 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =