15-12-常用对象API(String类-练习4-去除两端空白)
来源:互联网 发布:delete删除表数据 编辑:程序博客网 时间:2024/06/08 03:14
package cn.itcast.string.demo;public class StringTest4 {public static void main(String[] args) {/* * 4.模拟一个trim功能一致的方法 */String s = " abcd ";s = myTrim(s);System.out.println(s);}public static String myTrim(String s) {int start = 0, end = s.length() - 1;while(start<=end && s.charAt(start)==' '){start++;}while(start<=end && s.charAt(end)==' '){end--;}String sub = s.substring(start, end+1);return sub;}}
0 0
- 15-12-常用对象API(String类-练习4-去除两端空白)
- 字符串练习4:模拟一个trim功能一致的方法。去除字符串两端的空白
- 15-09-常用对象API(String类-练习1-字符串数组排序)
- 15-10-常用对象API(String类-练习2-子串的次数)
- 15-11-常用对象API(String类-练习3-最大相同子串)
- ios 字符串去除两端的空白 字符串去除所有空白
- JAVA学习第三十课(常用对象API)- String类:类方法练习
- String对象常用API
- 15-StringBuffer-13-常用对象API(StringBuilder类-练习)
- 15-01-常用对象API(String类-特点)
- 15-02-常用对象API(String类-构造函数)
- 15-05-常用对象API(String类-常见功能-转换)
- 15-06-常用对象API(String类-常见功能-判断)
- 15-07-常用对象API(String类-常见功能-比较)
- 15-08-常用对象API(String类-intern方法)
- 常用对象API(String类-特点)
- 4.1常用对象API(String类)
- string 中去除空白字符
- 360oj 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。
- 8月10日总结
- 15-11-常用对象API(String类-练习3-最大相同子串)
- 自动监控脚本
- 机器学习之实战朴素贝叶斯算法
- 15-12-常用对象API(String类-练习4-去除两端空白)
- css中position:relative和overflow:hidden的问题
- 360oj 字符串统计
- 零基础学python-2.4 操作符
- poj 2253 Longest Ordered Subsequence
- 求两个数的最大公约数和最小公倍数
- 15-StringBuffer-09-常用对象API(StringBuffer类-特点&添加功能)
- 【MySql】使用记录<四>
- HDU2183