Created
September 7, 2012 10:43
-
-
Save DominicFinn/3665033 to your computer and use it in GitHub Desktop.
Splits a string and puts spaces in it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Hello { | |
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
String answer = ""; | |
String result = ""; | |
char[] arrayOfCharacters; | |
System.out.println("Give me a string and ill put spaces in it"); | |
answer = input.nextLine(); | |
arrayOfCharacters = answer.toCharArray(); | |
for(int x = 0; x < arrayOfCharacters.length; x++) { | |
result = result + arrayOfCharacters[x] + " "; | |
} | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment