-
Separating Strings
Hello there!
I'm working on a program that will take an input (i.e: "This is a test"), and outputs it scrambled, but having the first and last letter of each word in the same place (i.e: "Tihs is a tset"). I know that I should first separate the input string into their own string values. I'm aware of using input.split(), but I'm not sure how to assign each word to it's own name (i.e: word1, word2, word3 etc...)
Any help would be appreciated!
Thank you,
Scorks
-
Re: Separating Strings
Strings can be concatenated. In other words you can add Strings with a + sign. e.g., String foo = "foo" + "bar" will result in "foobar". With this knowledge and a for loop, I'll bet you can figure this out.
Note, in the future there will be times when you'll want to use a StringBuilder to do this sort of concatenation, since it is more efficient at it, but for your simple needs, the benefit is less than minimal and so I suggest you keep things as simple as possible and just use plain String concatenation.