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

split method in java

public class SplitExample2 { 
    public static void main(String args[]) 
    { 
        String str = "My name is Chaitanya";
        //regular expression is a whitespace here 
        String[] arr = str.split(" "); 
  
        for (String s : arr) 
            System.out.println(s); 
    } 
}
Comment

split on . in java

String textfile = "ReadMe.txt";
String filename = textfile.split(".")[0];
String extension = textfile.split(".")[1];
Comment

split in java

String text = "Int--String";
String[] parts = text.split("--");
String part0 = parts[0];//"Int"
String part1 = parts[1];//"String"
System.out.println(part0/*"Int"*/ + " is a datatype for a number and a " + 
                  part1/*"String"*/ + " is a datatype for a text.");

// Output: Int is a datatype for a number and a String is a datatype for a text.
Comment

java split on {

String s = "abc{def";
String[] arr = s.split("{");
String s1 = arr[0]; // abc
String s2 = arr[1]; // def
Comment

string split java

String[] parts = string.split(Pattern.quote(".")); // Split on period.
Comment

PREVIOUS NEXT
Code Example
Java :: math.sin in java 
Java :: can a java class have more than 108 constructors 
Java :: java noverify 
Java :: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 
Java :: android press back 2 times to exit 
Java :: update in spring boot 
Java :: android alert change color 
Java :: width and height of screen java 
Java :: hangfire list recurring jobs 
Java :: android studio find all views in layout 
Java :: java exception to string 
Java :: difference between synchronized block and synchronized method example 
Java :: Java code to launch shell script with arguments 
Java :: Could not resolve project :app 
Java :: 2048 java code 
Java :: java string replace 
Java :: array of arraylist in java 
Java :: how to create textview in java android 
Java :: the import junit cannot be resolved maven 
Java :: mongorepository spring boot custom query 
Java :: array index out of bound exception in java 
Java :: Java Create a ByteArrayOutputStream 
Java :: terminate function calling in java 
Java :: iterate through arraylist java 
Java :: java comparator comparing 
Java :: java hashmap 
Java :: java returns null 
Java :: super class java 
Java :: java firebase syncrhonous data read 
Java :: how todo a timeout test java 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =