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

1 answer 133 views
1 answer 134 views
1 answer 126 views
3 answers 180 views
180 views asked May 30, 2023 by avibootz
1 answer 119 views
...