Write code to remove single and double quotes around a string
//package com.book2s; public class Main { public static void main(String[] argv) { String text = "'book2s.com'"; System.out.println(unquote(text)); }/* w ww . j a v a 2 s. com*/ /** * removes single and double quotes around a string * * @param text text to unquote * @return unquoted text */ public static String unquote(String text) { if ((text == null) || text.length() < 2) { return text; } if (text.charAt(0) == text.charAt(text.length() - 1)) { if (text.charAt(0) == '"' || text.charAt(0) == '\'') { return text.substring(1, text.length() - 1); } } return text; } }