How to replace comma (',') with newline ('\n') in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        String s ="java,c++,python,php";
    
        s = s.replaceAll(",", "\n");

        System.out.println(s);
    }
}



/*
run:

java
c++
python
php

*/

 



answered Apr 26, 2020 by avibootz

Related questions

...