Write code to search a char inside a string
//package com.book2s; public class Main { public static void main(String[] argv) { String str = "book2s.com"; char ch = 'a'; System.out.println(contains(str, ch)); }/*from ww w . j a v a 2s . c o m*/ public static boolean contains(final String str, final char ch) { if (isEmpty(str)) { return false; } return str.indexOf(ch) >= 0; } public static boolean contains(final String s1, final String s2) { if (isEmpty(s1)) { return false; } return s1.indexOf(s2) >= 0; } public static final boolean isEmpty(final String text) { return text == null || text.length() == 0; } }