[Solved] Inserting punctuation marks in a java String [closed]


How about this:

String greetings = "Hello" + "," + " how are you";

Or this:

String greetings = "Hello how are you";
greetings = greetings.substring(0, 5) + "," + greetings.substring(5);

Or this:

String greetings = "Hello how are you";
greetings = new StringBuilder(greetings).insert(5, ",").toString();

Inserting a punctuation mark is trivial if you know where it should go. But if you don’t know the exact place beforehand, it’s impossible!

5

solved Inserting punctuation marks in a java String [closed]