Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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);
Comment

split number java

int num = 5542;
String number = String.valueOf(num);
for(int i = 0; i < number.length(); i++) {
    int j = Character.digit(number.charAt(i), 10);
    System.out.println("digit: " + j);
}
Comment

java split int

String str = "1 16 217 22 992";

        String[] numbersAsStrings = str.split(" ");
        int[] numbers = new int[numbersAsStrings.length];

        for (int i = 0; i < numbersAsStrings.length; i++) {
            numbers[i] = Integer.parseInt(numbersAsStrings[i]);
        }
Comment

PREVIOUS NEXT
Code Example
Java :: How to efficiently find the next greater permutation of a list of values, in Java? 
Java :: timestamp to date java 
Java :: set java path on linux ubuntu 
Java :: How to connect from Android emulator to application on localhost? 
Java :: on selected item changed listview javafx 
Java :: Right triangle star pattern in java 
Java :: java how to convert string to int 
Java :: get year month day from date string java 
Java :: how to get child from layout in android 
Java :: Processing Java examples 
Java :: number of digits java 
Java :: Array list deep copy 
Java :: reverse int array java 
Java :: arraylist syntax in java 
Java :: sudoku solver 
Java :: arraylist of double 
Java :: how to right align in java 
Java :: intellisense for eclipse java 
Java :: how to update java on windows 10 
Java :: java read file 
Java :: string format java 
Java :: java random int between 2 numbers 
Java :: which api is android 12 
Java :: camera permission in android 
Java :: java iterate hashmap 
Java :: add two numbers bitwise 
Java :: enum java 
Java :: how to add a list in a list java 
Java :: android dialog box example 
Java :: set layout params in dp value 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =