Here you can find the source of lastIndexOf(String string, char... chars)
Parameter | Description |
---|---|
string | a parameter |
chars | a parameter |
public static int lastIndexOf(String string, char... chars)
//package com.java2s; /**// w w w .ja v a 2 s . c o m * Aptana Studio * Copyright (c) 2005-2012 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). * Please see the license.html included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ public class Main { /** * @see String#lastIndexOf(int) * @param string * @param chars * @return */ public static int lastIndexOf(String string, char... chars) { if (string == null) { return -1; } return lastIndexOf(string, string.length() - 1, chars); } /** * @see String#lastIndexOf(String, int) * @param string * @param fromIndex * @param chars * @return */ public static int lastIndexOf(String string, int fromIndex, char... chars) { if (chars == null || chars.length == 0) { return -1; } int length = string.length(); if (length == 0) { return -1; } else if (fromIndex >= length) { fromIndex = length - 1; } for (int i = fromIndex; i >= 0; i--) { char c = string.charAt(i); for (char x : chars) { if (c == x) { return i; } } } return -1; } }