string类很常用,很重要。
string不像int或float, 它是参考类型。final类型, 不能被继承,string is a reference type,南京景点介绍defined in java.lang package
马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
常用方法:
length()
string greeting = “hello”;
int n = greeting.length();//is 5
charat(n)(取某个位置字符)
char first = greeting.charat(0);
char last = greeting.charat(4);
substring()(取子字符串)
string s = greeting.substring(0,3);//from 0 inclusive to 3 exclusive
concatenation(链接)
string a = greeting + “ world!”+ 2009;
equality(don’t如何考上清华北大 u ==)(测试是否相等)
string s = “hello”;科学与生活 s.equals(greeting);
“hello”.equalsignoreca(“hello”);(忽略大小写的测试相等)
本章迪丽热巴 迪力木拉提源码
例子:
public class test {
public static void main(string args[]) {
strin那一次我真g letters = “abcdefghijklabcdefghijkl”;
/*这里讲讲阅读源代码,control点击进入方法*/
system.out.println(“‘c’在第” + letters.indexof(‘c’) + “个”);
本文发布于:2023-04-05 05:30:16,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/2b864aa6b253fa5c4dfd1870fc0f9c32.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:string类的常用方法(String类提供的合法的方法).doc
本文 PDF 下载地址:string类的常用方法(String类提供的合法的方法).pdf
留言与评论(共有 0 条评论) |