Write a program to remove all trailing space from a string.
Example:
Input: " Become code expert using beingCode expert"
Output: "BecomecodeexpertusingbeingCodeexpert"
Approach:
Java:
import java.util.regex.*;public class BeingCodeExpert {public static void main(String[] args) {String inputString = " Become code expert using beingCode expert";String outputString = inputString.replaceAll("\\s+", "");System.out.println(outputString);}}
No comments:
Post a Comment