zoukankan      html  css  js  c++  java
  • String类的一些方法

      String 类有以下方法:

    startsWith(String prefix)

    boolean java.lang.String.startsWith(String prefix)

    Tests if this string starts with the specified prefix.

    Parameters:
    prefix the prefix.
    Returns:
    true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise. Note also that true will be returned if the argument is an empty string or is equal to this String object as determined by the equals(Object) method.
    Since:
    1. 0
    就是判断字符串中的后缀是否为参数prefix,如果是就返回true,如果不是就返回false。
    这在安卓中可以用来识别音频文件,如mp3文件等。
    对应的,还有一个方法,
    endsWith(String suffix)
    boolean java.lang.String.endsWith(String suffix)

    Tests if this string ends with the specified suffix.

    Parameters:
    suffix the suffix.
    Returns:
    true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise. Note that the result will be true if the argument is the empty string or is equal to this String object as determined by the equals(Object) method.
    可以用来判断一个字符串是否以suffix这个参数开头。
  • 相关阅读:
    Java内置包装类
    for循环思路题
    常用函数
    函数
    冒泡排序
    数组的运用
    for循环中有意思的练习题。
    for循环
    运算中容易出现的错误
    分支的运用
  • 原文地址:https://www.cnblogs.com/Sunnor/p/4817613.html
Copyright © 2011-2022 走看看