String类型的常用
来源:互联网 发布:php文字特效代码 编辑:程序博客网 时间:2024/04/29 05:59
String 类型是java中重要的且实用的,今天使用了几个常用的方法;
public class StringTest{public static void main(String[] args){ String hello="hello"; String world="world";
//判断两个String类型字符是否相等; if(hello.equals(world)){ System.out.println("true"); }else{ System.out.println("false"); } //返回utf-16编码表示的给定字符串所需要的代码单元的数量; int n=hello.length(); System.out.println(n); //计算代码点的数量; int cpCount=hello.codePointCount(0, hello.length()); System.out.println(cpCount); char first=hello.charAt(0); char last=hello.charAt(3); System.out.println(first); System.out.println(last); 3.//返回给定位置开始或结束的代码点 int a=hello.codePointAt(3); System.out.println(a); 4.//判断字符串结尾 boolean f=hello.endsWith("o"); System.out.println(f); 5. //判断字符串是否相等 boolean x=hello.equals("hello"); System.out.println(x);}}
运行结果:
false;
5;
5;
h;
l;
108;
true;
true;
0 0
- String类型的常用
- string类型的常用操作
- java中String类型的常用操作
- String类型常用的方法汇总
- C# string类型中常用的API
- string类型常用方法总结
- Redis String类型数据常用的16条命令总结
- VS2010中String^的几个常用类型转换
- 常用类包括主要是string类型的
- C#中关于String类型的常用方法
- 常用object和String类型的相互转换
- c#之string类型的一些常用库函数
- 11.java语言基础-最常用的引用类型-string
- C#中string类型的常用方法总结
- String类型/Date类型常用方法总结
- string的类型转换
- String类型的比较
- String类型的点滴
- linux--IP地址转换函数
- com.model
- 【精华】CSDN 2016 大会PPT年终汇总
- Linux系统基础之三:Linux用户和用户组管理
- android高仿微信表情输入与键盘输入(详细实现分析)
- String类型的常用
- 如何将 Nginx 配置为Web服务器
- com.model
- [BZOJ3238][Ahoi2013]差异(后缀数组+单调栈||后缀自动机+树形dp)
- VMtool安装问题
- ArrayBuffer.isView、ArrayBuffer.transfer、Boolean、DataView、buffer、byteLength
- SSM框架整合
- MFC创建非模态对话框的debug assertion failed问题
- HttpWebRequest乱码