top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to Split String in java?

0 votes
74 views
How to Split String in java?
posted Jan 19, 2018 by Jon Deck

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

The java string split() method splits this string against given regular expression and returns a char array.

public String split(String regex)   and,  
public String split(String regex, int limit)

Paramater

regex : regular expression to be applied on string.

limit : limit for the number of strings in array. If it is zero, it will returns all the strings matching regex.

Example

String string = "Query-Home";
String[] parts = string.split("-");
String part1 = parts[0]; // Query
String part2 = parts[1]; // Home
answer Jan 23, 2018 by Chahat Sharma
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...