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 :: Adding in java using user input 
Java :: java count to 10 
Java :: timestamp with zone java 
Java :: jtable get get row 
Java :: generate serial uuid with intelij 
Java :: java array initialization 
Java :: how to make a loop in java 
Java :: sudoku solver 
Java :: min max heap java 
Java :: sort a string array java 
Java :: how to return array in java 
Java :: repository query spring boot 
Java :: android double click to exit 
Java :: how to update java on windows 10 
Java :: pointers in java 
Java :: convert double into integer 
Java :: java string to byte array utf8 
Java :: skip values in a for loop java 
Java :: how to change the value of an arraylist in java 
Java :: iterate hashmap java 
Java :: space seperator in string in java 
Java :: how to go to next iteration of while loop java 
Java :: java exception list 
Java :: java mail use tls 1.2 
Java :: HOW TO PARSE a string into a number in java 
Java :: maven artifact 
Java :: add element in the last in double linked list in java 
Java :: send message bukkit 
Java :: spring boot dockerfile 
Java :: binary to octal conversion java program 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =