Write a program to split a string without using - TopicsExpress



          

Write a program to split a string without using split()method package com.raghu.string; import java.util.ArrayList; /* This is for spliting a string without using split method. Also this split method does not take regex as input. It can take at max two chars, in case of two chars it expects first char as \ for special chars in string. */ public class SplitString { String S; public SplitString(String s){ S = s; } public String[] split(String regex){ char ch; if(regex==null||regex.length()>;2) return null; else if(regex.length()==2&®ex.charAt(0)==\\) ch = regex.charAt(1); else ch = regex.charAt(0); String[] result=null; ArrayList stringList = new ArrayList(); StringBuilder str= new StringBuilder(); for(int i=0;i
Posted on: Mon, 27 Oct 2014 13:45:19 +0000

Trending Topics



Recently Viewed Topics




© 2015