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 :: max heap java 
Java :: set size button java 
Java :: method returns arraylist java 
Java :: How to generate all possible IP addresses based on a given set of digits, in Java? 
Java :: activitycompat.requestpermissions not working 
Java :: break java 
Java :: reverse a integer in java 
Java :: add opacity to activity android 
Java :: declaration of double array in java 
Java :: how to create an action listener in java 
Java :: How to connect from Android emulator to application on localhost? 
Java :: spring boot actuator 
Java :: how to convert a number into a decimal number in java 
Java :: discord jda 
Java :: java quick sort 
Java :: How to efficiently convert a sorted array into a min height binary search tree, in Java? 
Java :: set path in windows 
Java :: open website from android activity 
Java :: java extract zip 
Java :: default argument in java 
Java :: how to get color from resource android 
Java :: java clone matrix 
Java :: difference between two LocalDateTime java 
Java :: armstrong number in java 
Java :: encapsulation in oop 
Java :: dot operator java 
Java :: display in java 
Java :: Java How to use SortedSet? 
Java :: java method reference 
Java :: android menu change text color 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =