Java - Write code to check if a string contains a char

Requirements

Write code to check if a string contains a char

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        char searchChar = 'o';
        System.out.println(contains(str, searchChar));
    }/*from w w  w . j  a  v a2  s. c om*/

    public static boolean contains(String str, char searchChar) {
        if ((str == null) || (str.length() == 0)) {
            return false;
        }

        return str.indexOf(searchChar) >= 0;
    }

    public static boolean contains(String str, String searchStr) {
        if ((str == null) || (searchStr == null)) {
            return false;
        }

        return str.indexOf(searchStr) >= 0;
    }

}