Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

How to split a string in Java

String string = "004-034556";
String[] parts = string.split("-");
String part1 = parts[0]; // 004
String part2 = parts[1]; // 034556
Comment

java split string

String yourString = "Hello/Test/World";
String[] strings = yourString.split("/" /*<- Regex */); 

Output:
strings = [Hello, Test, World]
Comment

java split string array

Java example to split a string
String str = "A-B-C-D";
String[] strArray = str.split("-"); 
 
System.out.println(Arrays.toString(strArray));  // [A, B, C, D]
Comment

split string into array java

String[] array = values.split("|", -1);
Comment

java how to split a string to array

String str= "abcdef";

        String[] array=str.split("(?<=G.{2})");

        System.out.println(java.util.Arrays.toString(array));   
Comment

Split string into a string array

public class MyClass {
    public static void main(String args[]) {
        String data = "1,2,3,,5,6,,";
        String[] split = data.split(",", -1);
        for (int i=0; i<split.length; i++)
            System.out.println(split[i]);
            
        System.out.println("Done");
        
    }
}
Comment

string split to list java

List<String> list = new ArrayList<String>(Arrays.asList(scanner.nextLine().split(", ")));
Comment

PREVIOUS NEXT
Code Example
Java :: java replace character 
Java :: how to output sum of even numbers in java between two user values 
Java :: how to import class from another file in java 
Java :: java insert at index 
Java :: diamond star pattern in java 
Java :: java string length validation regex 
Java :: BST in java 
Java :: encapsulation in oop 
Java :: which api is android 12 
Java :: java formatted output 
Java :: java instance of a class 
Java :: java repository sql find not in list 
Java :: How to draw Bezier Curve in Android 
Java :: java.lang.ArrayIndexOutOfBoundsException 
Java :: Android Bitmap to Base64 String 
Java :: I/flutter (10109): {filePath: null, errorMessage: java.io.FileNotFoundException: open failed: EACCES (Permission denied), isSuccess: false} 
Java :: java mail use tls 1.2 
Java :: center textview programmatically android 
Java :: java multiple catch blocks 
Java :: nosuchelementexception 
Java :: add Duration to date in Kotlin 
Java :: runnable java 
Java :: what coding language is minecraft 
Java :: how to subtract localdatetime in java 
Java :: checkc if string is double java 
Java :: bufferedinputstream 
Java :: The this(Keyword) 
Java :: java string from byte array 
Java :: how to add a listener to a toggle group radio buttons javafx 
Java :: declare a hashmap in java 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =