Hey_Donny

endsWith

Apr 11th, 2022
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. /**
  2. * Checks if provided String ends with char from target.
  3. * @param source String that we check
  4. * @param target Char that we check for
  5. * @return boolean that states if source does or doesn't end with char from target.
  6. * @author Dimitar Naydenov
  7. */
  8. public static boolean endsWith(String source, char target) {
  9. String[] arr = source.split("");
  10. if (arr[arr.length - 1].equals(Character.toString(target))) {
  11. return true;
  12. }
  13. return false;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment