Saturday 23 December 2017

Write a program to Remove the black space from given sentence in java

Write a program to Remove the black space from given sentence in java, how to Remove the black space from given sentence in java, Remove the black space from given sentence,wap to Remove the black space from given sentence,

package com.dashzin.prog;

public class BlanclSpace {

public static void main(String[] args) {
String st="welcome to dashzin blog";
 
// using replaceAll method
String s=st.replaceAll(" ", "");
System.out.println(s);
 
// without using pridefined method
 
char ch[]=st.toCharArray();
StringBuffer sb=new StringBuffer();
  for(int i=0;i<ch.length;i++){
  if(ch[i]!=' ' && ch[i]!='\t'){
  sb.append(ch[i]);
  }
  }
String st1=sb.toString();
System.out.println(st1);

}

}

Output

welcometodashzinblog
welcometodashzinblog




DashZin

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment