Scanner in = new Scanner(System.in); System.out.print("Enter a text: "); String text = in.nextLine(); int index=0; int L = text.length(); while(index<L){ if(index==L-1){ System.out.print(text.charAt(index)); break; } System.out.print(text.charAt(index).concat(" ")); index++; }
My code has a problem and it's that I can not call concat() methode because 'text.charAt(index)' has primitive type char, I don't understand what's the problem, can someone please let me know?