I'm a newbie to Java and I'm trying to write a class which will parse a search string, put each word from the string into an array and then return the array, but it won't work no matter what I do. Please help.
The class to test it is here:
Code:
import java.util.regex.*;
import java.util.*;
public class SearchStringArray
{
String searchString;
String boundaryCharacter = " ";
public String[] SearchStringArray(String s)
{
String[] searchArray;
searchString = s;
Pattern space = Pattern.compile(boundaryCharacter);
searchArray = space.split(searchString);
return searchArray;
}
}
The class to test it is here:
Code:
import java.util.*;
public class Testssa
{
public static void main(String[] args)
{
String search1 = "xdv hs5";
SearchStringArray[] newone = new SearchStringArray(search1);
for (int i=0; i<newone.length; i++ )
{
System.out.println(newone.length);
}
}
}