String Question 7
Question 7.Write a Program to remove spaces from a string.
Program-
class Solution { String modify(String S) { StringBuilder sb = new StringBuilder(); for(int i=0; i<S.length(); i++){ if(S.charAt(i) ==' ') { continue; } sb.append(S.charAt(i)); } return sb.toString(); } } |