Split string by , (comma)
public class Main {
public static void main(String[] args) {
String str = "one,two,three,four,five";
String[] elements = str.split(",");
for (int i = 0; i < elements.length; i++)
System.out.println(elements[i]);
}
}
Output:
one
two
three
four
five
Home
Java Book
Runnable examples
Java Book
Runnable examples
Data Type String:
- Compare String with compareTo method
- Compare strings ignoring case
- Compare Strings with equals
- Compare string with a StringBuffer
- Convert Primitive Type Value to a String
- Convert String value to byte
- Convert String to primitive byte by parseByte
- Convert String to byte
- Convert String to byte array
- Convert String to Boolean
- Convert string to char array
- Convert String to double
- Convert String to float
- Convert binary string into integer
- Convert String to int
- Convert String to Long
- Convert a string to a number
- Convert String to Short
- Convert hex String To Byte Array
- Convert Octal string to integer
- Convert String to Lower Case
- Convert String to Upper Case
- Convert string to uppercase for a Locale
- Convert characters in a string to a Set
- Capitalize/Uncapitalize the first character converted to uppercase
- Capitlize each word in a string (journal titles, etc)
- Count letters in a String
- Count numbers in a String
- Count the number of occurrences of character c in a string.
- Check each char value from a string
- Count substring Occurrences
- Convert char in a String to Ascii code
- Convert Character array to String
- Encode a string in UTF-8
- Encode string in UTF-8 byte[]
- Encode UTF-8 from Unicode
- Escape string
- Format strings into table
- Format string to Center
- Justify left string
- Justify right string
- Length of things
- Hash Code String
- Is String is a Legal Java Identifier
- Is String empty (""), null and whitespace
- Is a string a palindrome
- Pad right a string
- Pad left a string
- Remove a substring
- Remove leading white space from a string
- Remove specified chars from a string
- Remove trailing whitespace
- Replace Characters in a String
- Replace multiple whitespaces between words with single blank
- Replace first occurrences of given String with new one
- Replace all occurrences of given String with new one and returns new String object.
- Replace new line sign
- Replace a character at a specified position
- Reverse a string
- Search a substring
- Search a Substrings for First occurrence
- Search a substring for Last occurrence
- Search substring anywhere, ignore case( regular expressions )
- ends With string
- Ends with, ignore case( regular expressions )
- starts With string
- Starts with, ignore case( regular expressions )
- starts with a digit or uppercase letter
- Split string by a whitespace character
- Split string by space
- Split string by - (hyphen)
- Split string by dot
- Split string by | (bar)
- Split string by , (comma)
- Split string for the maximum number of substrings
- Split with regular expression
- Split string by Pattern for space splittor
- Split Strings with -/%s
- Split string on word boundaries.
- Split string on commas and zero or more spaces.
- Split string on word boundaries, but allow embedded periods and @.
- Split string on punctuation and zero or more trailing spaces.
- Split string with and's and or's
- Sort string array in case insensitive order and case sensitive order
- Substring
- Trim leading and trailing space from String
- Trim double quotes
- Unquote string
- Wrap Word
- Break Lines
- Abbreviates a String using ellipses.
- Delimit a string
- Unaccent letters