Write code to trim Last Slash
//package com.book2s; public class Main { public static void main(String[] argv) { String str = "book2s.com/"; System.out.println(trimLastSlash(str)); }/*from ww w . j av a 2 s . co m*/ public static String trimLastSlash(String str) { if (str.endsWith("/")) { return str.substring(0, str.length() - 1); } return str; } }