How to remove the last comma from the end of string in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        String str = "java,c,c++,python,";
 
        str = str.substring(0, str.length() -1);

        System.out.println(str);
    }
}

   
   
   
   
/*
run:
   
java,c,c++,python
   
*/

 



answered Jun 9, 2022 by avibootz

Related questions

1 answer 182 views
1 answer 155 views
1 answer 138 views
1 answer 141 views
1 answer 150 views
2 answers 186 views
2 answers 184 views
...