Java String Starts Wtih startsWith(String str1Raw, String str2Raw)

Here you can find the source of startsWith(String str1Raw, String str2Raw)

Description

starts With

License

Apache License

Declaration

public static boolean startsWith(String str1Raw, String str2Raw) 

Method Source Code

//package com.java2s;
/*/*ww  w  .  j  a  v  a  2  s  .  c  om*/
 Copyright 2014 Reo_SP
    
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
    
http://www.apache.org/licenses/LICENSE-2.0
    
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/

public class Main {
    public static boolean startsWith(String str1Raw, String str2Raw) {
        String str1 = str1Raw.toLowerCase();
        String str2 = str2Raw.toLowerCase();

        for (int i = 0; i < str1.length() && i < str2.length(); i++) {
            if (str1.charAt(i) != str2.charAt(i)) {
                return false;
            }
        }

        return true;
    }
}

Related

  1. StartsWith(String str, String prefix)
  2. startsWith(String str, String prefix, boolean ignoreCase)
  3. startsWith(String str, String prefix, boolean ignoreCase)
  4. startsWith(String str, String prefix, int index)
  5. startsWith(String str, String start, boolean caseSensitive)
  6. startsWith(String string, char... ca)
  7. startsWith(String string, String prefix)
  8. startsWith(String string, StringBuffer prefix, int toffset)
  9. startsWith(String target, String... prefixes)