« Back
package com.string; public class StringSplit { public static void main(String[] args) { String[] stringArr1; String[] stringArr2; String s = "coders-arts-sof-stack"; stringArr1 = s.split("-"); System.out.println("String splited by given Expression"); for(String strings : stringArr1) { System.out.println(strings); } stringArr2 = s.split("-",3); System.out.println("String splited by given Expression and limit"); for(String strings : stringArr2) { System.out.println(strings); } } }
String splited by given Expression
coders
arts
sof
stack
String splited by given Expression and limit
coders
arts
sof-stack
×
Report a Problem:
Description:
Submit