Shorter would be using a regex:
System.out.println("Joe".replaceAll(".(?!$)", "$0 "));
More Related Contents:
- foo(int) is not applicable for the arguments (String)
- Replace a character specific number of times in String Java
- How can I pad a String in Java?
- Comparing strings with == which are declared final in Java
- Difference between String replace() and replaceAll()
- How can I check if a single character appears in a string?
- In Java, how do I check if a string contains a substring (ignoring case)? [duplicate]
- Android Split string
- How do I convert CamelCase into human-readable names in Java?
- String comparison and String interning in Java
- What is the simplest way to convert a Java string from all caps (words separated by underscores) to CamelCase (no word separators)?
- Java String.split() Regex
- How can I invert the case of a String in Java?
- Why does this code using random strings print “hello world”?
- Remove all empty lines
- Does concatenating strings in Java always lead to new strings being created in memory?
- Java: String split(): I want it to include the empty strings at the end [duplicate]
- How can I safely encode a string in Java to use as a filename?
- How do I convert a String to a BigInteger?
- How to properly trim whitespaces from a string in Java?
- Why is String.length() a method?
- Is it possible to change the text color in a string to multiple colors in Java?
- Java compressing Strings
- Java String ReplaceAll method giving illegal repetition error?
- Unable to print russian characters
- Translating strings character by character
- Using DocumentFilter.FilterBypass
- Can we access or query the Java String intern (constant) pool?
- Java printf using variable field size?
- Extract digits from string – StringUtils Java