1.

字符串转大写: toUpperCase()

字符串转小写: toLowerCase()
    @Test
public void tt(){
String d = "sdgGHJGjghGHJGHG";
System.out.println(d);
System.out.println(d.toUpperCase());
System.out.println(d.toLowerCase()); }

打印

2.

去掉首末端空格: trim()
    @Test
public void tt(){
String d = "sdgGHJGjghGHJGHG ";
System.out.println(d+"ff");
System.out.println(d.trim()+"ff");
}

打印

3.

根据索引切割字符: substring()
注意substring 切割的是包含首字符,不包含尾字符,即 [ , )
如果只有一个参数,如
String s = "12345";
System.out.println(s.substring(2));
打印为345
也就是说s.substring(2)相当于s.substring(2,s.length())
截取后面所有

    @Test
public void tt(){
String d = "1+1=2";
System.out.println("字符串长度,即字符个数:"+d.length());
//注意substring 切割的是包含首字符,不包含尾字符,即 [ , )
System.out.println(d.substring(1,3));
}

打印

4.

判断是否含有某连续字符串 :contains()
    @Test
public void tt(){
String d = "1+1=2";
System.out.println(d.contains("1="));
System.out.println(d.contains("2="));
}

打印

java 字符串 大小写转换 、去掉首末端空格 、根据索引切割字符 、判断是否含有某连续字符串的更多相关文章

  1. java字符串大小写转换的两种方法

    转载自:飞扬青春sina blogjava字符串大小写转换的两种方法 import java.io..* public class convertToPrintString {          pu ...

  2. 【转】Python 字符串大小写转换

    转载自:python 中字符串大小写转换 一.pyhton字符串的大小写转换, 常用的有以下几种方法: 1.对字符串中所有字符(仅对字母有效)的大小写转换,有两个方法: print 'just to ...

  3. [Swift]字符串大小写转换,同时实现本地化或设置语言环境

    在NSString中提供了3种字符串大小写转换方式:1. 转换字符串大小写2. 转换字符串大小写,并实现本地化3. 转换字符串大小写,并设置语言环境. 一. 转换字符串大小写如果只是想单纯的将字符串进 ...

  4. linux bash shell:最方便的字符串大小写转换(lowercase/uppercase conversion) (转)

    原文地址:https://blog.csdn.net/10km/article/details/83384145 关于字符串大小写转换,是写 linux 脚本经常干的事儿,所以总想找个方便的方法让我少 ...

  5. python 字符串大小写转换(不能使用swapcase()方法)

    python 3字符串大小写转换 要求不能使用swapcase()方法 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wa ...

  6. boost 字符串大小写转换

    示例代码如下: #include <boost/algorithm/algorithm.hpp> #include <iostream> using namespace std ...

  7. std::string 字符串大小写转换(转)

    该问题归结为std::transform函数的使用 函数原型 template < class InputIterator, class OutputIterator, class UnaryO ...

  8. php字符串大小写转换

    strtoupper().strtolower().ucfirst().ucfirst().ucwords().mb_strtoupper().mb_strtolower()和mb_convert_c ...

  9. java字符串大小写转换

    String test="SHA34cccddee";    System.out.println(test.toUpperCase());//小写转大写 String test= ...

随机推荐

  1. Linux Ubuntu18.04 安装配置 clash

    我最近一段时间在搭建用于构建 Docker 镜像的开发测试环境,这个环境是一台运行于 Windows 笔记本上的虚拟机,其操作系统为 Ubuntu 18.04 .构建场景中经常要去 Github 获取 ...

  2. ubuntu 16.04下的fastadmin安装指南

    此篇博客转载于fastadmin论坛,方便自己看转到了博客里 说明文档不多,特制作一个,方便大家交流使用Ubuntu 16.04 安装fastadmin指南本文因考虑到大多数人员,习惯性在window ...

  3. Windows11下载地址

    10月5日微软推出了Win11正式版本,但是仍然不支持apk格式,不免让人失望.下面是Win11商业版本下载地址: 下载地址1: ed2k://|file|zh-cn_windows_11_busin ...

  4. 统计函数(Excel函数集团)

    此处文章均为本妖原创,供下载.学习.探讨! 文章下载源是Office365国内版1Driver,如有链接问题请联系我. 请勿用于商业! 谢谢 下载地址:https://officecommunity- ...

  5. M-SOLUTIONS Programming Contest 2021(AtCoder Beginner Contest 232) 题解

    目录 G - Modulo Shortest Path H - King's Tour 因为偷懒就只写G和H的题解了. G - Modulo Shortest Path 首先可以观察到对于一条从点\( ...

  6. Codeforces Round #665 (Div. 2) 题解

    Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...

  7. UVA294 约数 Divisors 题解

    Content 给定 \(n\) 个区间 \([l,r]\),求出每个区间内约数个数最大的数. 数据范围:\(1\leqslant l<r\leqslant 10^{10}\),\(r-l\le ...

  8. 实时&离线皮肤渲染技术(Real-time&Offline Skin Rendering)

    目录 现实皮肤模型 BSSRDF 渲染模型 [2001] Diffusion Profile(扩散剖面)[2001] 偶极子 [2002] 高斯和 [2007] Burley Normalized D ...

  9. JAVA读取本地html文件里的html文本

    /** * 读取本地html文件里的html代码 * @param file File file=new File("文件的绝对路径") * @return */ public s ...

  10. JAVA通过经纬度获取两点之间的距离

    private static double EARTH_RADIUS = 6378.137; private static double rad(double d) { return d * Math ...