-4

I'm trying to create a program in Java that takes user input and converts it into Pig Latin. To do this, I am planning to get the user input, store it as a String, and somehow convert it to an array so I am able to work with each individual word in there.

How should I go about this?

Dirk Lachowski
  • 3,121
  • 4
  • 40
  • 66
bigbeno37
  • 5
  • 2
  • 2
    One would start by reviewing the spec for [String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html). – Hot Licks Mar 25 '14 at 23:12
  • I would recommend looking into the java Scanner class and showing attempted code BEFORE posting to stackoverflow. Also your tags do not match the question. – Nick Mar 25 '14 at 23:14

2 Answers2

0

I like Commons Lang StringUtils, which has a split method with various options. The default splits by whitespace.

 String[] parts = StringUtils.split(theString);
Thilo
  • 257,207
  • 101
  • 511
  • 656
0

split();

try {
    String[] splitArray = yourString.split("\\s+");
} catch (PatternSyntaxException ex) {

}

I would recommend You check the Java docs, as there are many ways of doing that. (i.e StringTokenizer)

MrHaze
  • 3,786
  • 3
  • 26
  • 47