Here you can find the source of endsWithIgnoreCase(String haystack, String needle)
Parameter | Description |
---|---|
haystack | the main string |
needle | the string to test against the main string |
public static boolean endsWithIgnoreCase(String haystack, String needle)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . j a v a2 s.c o m * Checks to see if a string ends with another string in a case-insensitive manner. * * @param haystack the main string * @param needle the string to test against the main string * @return true if it matches, false otherwise */ public static boolean endsWithIgnoreCase(String haystack, String needle) { if (needle.length() > haystack.length()) { return false; } for (int i = 0; i < needle.length(); i++) { int start = haystack.length() - needle.length() + i; if (!haystack.substring(start, start + 1).equalsIgnoreCase(needle.substring(i, i + 1))) { return false; } } return true; } }