String类的一些方法
String 类有以下方法:
startsWith(String prefix)
Tests if this string starts with the specified prefix.
- Parameters:
- prefix the prefix.
- Returns:
trueif the character sequence represented by the argument is a prefix of the character sequence represented by this string;falseotherwise. Note also thattruewill be returned if the argument is an empty string or is equal to thisStringobject as determined by theequals(Object)method.- Since:
- 1. 0
- 就是判断字符串中的后缀是否为参数prefix,如果是就返回true,如果不是就返回false。
- 这在安卓中可以用来识别音频文件,如mp3文件等。
- 对应的,还有一个方法,
- endsWith(String suffix)
-
Tests if this string ends with the specified suffix.
- Parameters:
- suffix the suffix.
- Returns:
trueif 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 betrueif the argument is the
empty string or is equal to thisStringobject as determined by the
equals(Object)
method.- 可以用来判断一个字符串是否以suffix这个参数开头。
String类的一些方法的更多相关文章
- 关于JAVA的String类的一些方法
一.得到字符串对象的有关信息 1.通过调用length()方法得到String的长度. String str=”This is a String”; int len =str.length(); 2. ...
- C++ string 类的 find 方法实例详解
1.C++ 中 string 类的 find 方法列表 size_type std::basic_string::find(const basic_string &__str, size_ty ...
- java.lang.String 类的所有方法
java.lang.String 类的所有方法 方法摘要 char charAt(int index) 返回指定索引处的 char 值. int codePointAt(int index) 返回指定 ...
- Java中String类的format方法使用总结
可参考: http://www.cnblogs.com/fsjohnhuang/p/4094777.html http://kgd1120.iteye.com/blog/1293633 String类 ...
- String类的split方法以及StringTokenizer
split方法可以根据指定的表达式regex将一个字符串分割成一个子字符串数组. 它的参数有两种形式,也即:split(String regex)和split(String regex, int li ...
- ASP.Net string 类的扩展方法 [转]
string 类的扩展方法列表(基本相同于 IEnumerable<T> 接口的成员列表): Aggregate<> //累加 All<> / ...
- String类的indexOf方法的用法和举例
2017年3月3号博主第一次去郑州互联网公司面试,背景是这样的我先前去了农大龙子湖校园招聘投简历,然后第二天去面试了那经历可以说是很失败的一次面试,当然这跟自己的水平有关了接下来重点讲一下面试的题目: ...
- Servlet 中为多项选择题判分---String类的indexOf()方法妙用
首先来看一下String类的indexOf()方法的用法: public class FirstDemo1 { /** *API中String的常用方法 */ // 查找指定字符串是否存在 publi ...
- Java字符串的匹配问题,String类的matches方法与Matcher类的matches方法的使用比较,Matcher类的matches()、find()和lookingAt()方法的使用比较
参考网上相关blog,对Java字符串的匹配问题进行了简单的比较和总结,主要对String类的matches方法与Matcher类的matches方法进行了比较. 对Matcher类的matches( ...
随机推荐
- php开发中的一些常用统计的日期
<?php echo '<br>今天:<br>'; echo date("Y-m-d",strtotime("now")), &q ...
- pure学习笔记
最近研究Pure,发现这个对于写css来说确实是个好的框架,特此总结了一番,如有错误或不足的地方,欢迎交流指点,轻拍. 此文运用的是优雅的Markdown而书 Pure学习笔记 #写在最前 1# Pu ...
- JS数组方法总结
数组的常用方法总结 不改变原数组 1.Array.length; //获取数组长度 2.Array.join(); ...
- php基础知识(有代码有注释)
回顾 数组: 数据的组合 数组定义: 三种方式(常用array()) 数组访问: 下标 数组分类: 关联数组, 索引数组和混合数组 数组循环遍历: foreach遍历(foreach原理) 二维数组: ...
- [LeetCode]题解(python):130-Surrounded Regions
题目来源: https://leetcode.com/problems/surrounded-regions/ 题意分析: 给定给一个二维的板,这个板只包括‘X’和‘O’.将被‘X’包围的‘O’变成‘ ...
- nrf51 SDK自带例程的解读
简单的pwm电机控制示例 simple_pwm_motor_control_example 其实就是pwm控制led的亮度 1.首先设置gpiote 设置初始为高电平2.接着设置ppi 定时器time ...
- ftp一些东东
ftp如果绑定域名 登录时登录名应该写成 域名|用户名
- 转载Spring IntrospectorCleanupListener
"在服务器运行过程中,Spring不停的运行的计划任务和OpenSessionInViewFilter,使得Tomcat反复加载对象而产生框架并用时可能产生的内存泄漏,则使用Introspe ...
- 笔试题引出float数据的存储方式的深究
笔试题: #include <iostream>#include <stdio.h>#include <string.h>#include <conio.h& ...
- HDU 2087 剪花布条 KMP入门
Problem Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条.计算一下能从花布条中尽可能剪出几块小饰条来呢? Input ...