Write code to remove substring from End
//package com.book2s; public class Main { public static void main(String[] argv) { String str = "book2s.com"; String remove = "com"; System.out.println(removeEnd(str, remove)); }//from w ww. j a v a2s. co m public static String removeEnd(String str, String remove) { if (isEmpty(str) || isEmpty(remove)) { return str; } if (str.endsWith(remove)) { return str.substring(0, str.length() - remove.length()); } return str; } public static boolean isEmpty(String chkStr) { if (chkStr == null) { return true; } else { return "".equals(chkStr.trim()) ? true : false; } } }