Removing white spaces from string

package view.bean;

public class RemoveWhiteSpace {
    public RemoveWhiteSpace() {
        super();
    }
   
    public static void main(String[] args){
        String str ="I love Andhra";
        for(int i=0; i<str.length(); i++){
           
            if(str.charAt(i)!= ' '){
                System.out.print(str.charAt(i));
            }
        }
        System.out.println(" with for-exh loop array");
        char[] ch = str.toCharArray();
        for(char i : ch){
            if(i!=' '){
            System.out.print(i);
            }
        }
       
    }
}

Comments