Just use the following code:
String emailList="AA,BB,CC"; emailList=emailList.replaceAll(",", "\n"); System.out.println(emailList);
Output
AA BB CC
Now, based on your code, your method looks like this:
public String getFormattedEmails(String emailList) { String emails=emailList.replaceAll(",", "\n"); return emails; }
Hope this helps:
source share