[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>char类型
* 在Java中char(2个字节)类型描述了UTF-16编码中的一个代码单元,除非确实要处理UTF-16代码单元,最好将字符串作为抽象数据类型处理
<>字符串(String)(StringBuffer和StringBuilder待添加)
*
Java的字符串就是Unicode字符序列,Java没有内置的字符串类型,而是在标准Java库中提供了一个预定义类,叫做“String”,它的实例用双引号括起来
例如 String e = " "; //一个空字符串 String greeting = "Hello"; <>String 中常见的方法
* substring()
作用:从较大的字符串中提取一个子串
例如: String greeting = "Hello"; String s = greeting.substring(0,3);
//调用该方法之后,s="Hel",只会抽取位置为3之前的,即(0,1,2)(不包括位置为3)的,其长度也非常好计算,len=3-0=3.
* “+”拼接
Java语言允许使用“+”连接两个字符串,需要注意的是,如果是将字符串和非字符串进行连接,后者则会被转换为字符串(在Java中,任何一个字符串都可以转换成字符串)
例如:
例子1.普通拼接
String expletive = "Expletive"; String PGL3 = "deleted"; String message =
expletive+ PGL3; //message = Expletivedeleted
例子2.字符串与其他类型的拼接
int a = 13; String name = "name" + a; //结果为"name13"
例2的特性则被运用到输出语句中,我们经常用到的
*
equals()
作用: 可以用来检测两个字符串是否相等(内容),例如表达式:
s.equal(t)
如果字符串s与字符串t相等,则返回true,否则返回false。
注意:不要使用==检测两个字符串是否相等,该运算符只能检测两个字符串是否放在同一个位置上
*
length()
作用:返回该字符串的长度
String greeting = "Hello"; int n = greeting.length(); //长度为5
像String.charAt(int index),可以返回该位置的代码单元,String有很多有用的方法,想要了解更多请查看API