Advertisement
Guest User

Untitled

a guest
May 6th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. package com.sample.test;
  2.  
  3. public class CommaStripper {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         String testString = "how are,you,my friend,";
  8.         CommaStripper stripper = new CommaStripper();
  9.         System.out.println(stripper.stripCommas(testString));
  10.    
  11.     }
  12.    
  13.     private String stripCommas(String line){
  14.         String finalString = null;
  15.         finalString = line.replaceAll(",$", "").trim();
  16.         return finalString;
  17.     }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement