Answers for "java separate the numbers from string array"

1

java separate the numbers from string

// string contains numbers
        String str = "The price of the book is $49";
        // extract digits only from strings
        String numberOnly = str.replaceAll("[^0-9]", "");
        // print the digitts
        System.out.println(numberOnly);
Posted by: Guest on October-25-2021
0

split string into int array

String[] strArray = input.split(",");
int[] intArray = new int[strArray.length];
for(int i = 0; i < strArray.length; i++) {
    intArray[i] = Integer.parseInt(strArray[i]);
}
Posted by: Guest on July-08-2020

Code answers related to "java separate the numbers from string array"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language