java笔记
字符串
String 变量还可以存放一个特殊的值,名为null , 这表示目前没有任何对象与该变量关联!
//检查一个字符串是否为null if(str == null); //检查一个字符串既不是null 也不为空串 if (str != null && str.length() != 0); //首先要检查str不为null
GB2312 是对 ASCII 的中文扩展。【占用2字节】
[编码格式简介(ANSI、GBK、GB2312、UTF-8、GB18030和 UNICODE)] https://blog.youkuaiyun.com/ldanduo/article/details/8203532/
charAt() 方法用于返回指定索引处的字符。索引范围为从 0 到 length() - 1。
public class Test {
public static void main(String args[]) {
String s = "www.runoob.com";
char result = s.charAt(6);
System.out.println(result);
}
}
//运行结果 n
大多数的常用Unicode 字符使用一个代码单元就可以表示,而辅助字符需要一对代码单元表示。
要想得到第i 个码点,应该使用下列语句
nt index = greeting.offsetByCodePoints(0, i); int cp = greeting.codePointAt(index);
本文介绍了Java中字符串的使用,包括如何检查字符串是否为null,以及字符串编码的相关知识,如GB2312是ASCII的中文扩展,占用2字节。还讲解了charAt()方法用于获取字符串指定位置的字符,并探讨了Unicode字符的表示方式。此外,文章提到了如何通过offsetByCodePoints和codePointAt方法获取Unicode码点。
3398

被折叠的 条评论
为什么被折叠?



