I am trying to find a way where i can get the user to enter a string e.g. "Hello my name is mr. blobby" then break this down into individual chars and print them out so it prints them out like so:
{'H', 'e', 'l', 'l', 'o', 'm', 'y'}
so far i have this:
String userInputString;
HashMap hm = new HashMap();
Scanner userInput = new Scanner( System.in );
System.out.println("Type a string: ");
userInputString = userInput.next();
char ui = userInputString.charAt(0);
char[] ui_arr = userInputString.toCharArray();
for(int i=0;i<ui_arr.length;i++){
System.out.print(String.valueOf(ui_arr[i]));
this takes the input from the user and prints them out. however, i want them to be printed comma seperated rather than they are typed in. thanks