Write code to compare two string for equal ignore Case And Space and handle null value
//package com.book2s; public class Main { public static void main(String[] argv) { String one = "book2s.com"; String another = "book2s.com"; System.out.println(equalignoreCaseAndSpace(one, another)); }//from w ww.jav a 2 s . c om public static boolean equalignoreCaseAndSpace(String one, String another) { if (one == null) { return another == null; } if (another == null) { return false; } return one.trim().equalsIgnoreCase(another.trim()); } public static String trim(String str) { return (str == null) ? null : str.trim(); } }