API 字符与字符串的运用(1)
来源:互联网 发布:逆向歧视知乎 编辑:程序博客网 时间:2024/04/25 07:29
public class StringDemo1 {
public static void main(String[] args) {
/*
//Character字符包装器类
char number = '3';
char letter = 'f';
System.out.println("这些都是字母:" + Character.isLetter(letter)); //true
System.out.println("这些都是数字:" + Character.isDigit(number)); //true
System.out.println("这个字母是大写:" + Character.isUpperCase('A')); //true
System.out.println("这个字母是小写:" + Character.isLowerCase('m')); //true
System.out.println("字母a的返回值大写为:" + Character.toUpperCase('a')); //A
System.out.println("字母A的返回值小写为:" + Character.toLowerCase('A')); //a
System.out.println("字符m的返回String对象为:" + Character.toString('m'));//m
*/
/*
//转义字符
System.out.println("She said \"Hello!\" to me."); //She said "Hello!" to me.
*/
// //获取字符串的长度
// String hello = "大家好,我是张小强!";
// int len = hello.length();
// System.out.println(hello + "的长度是:" + len);
// System.out.println(hello + "的长度是:" + hello.length());
//连接字符串
// String str1 = "hello,";
// String str2 = "my name is Jack!";
// String str3 = str1.concat(str2); //连接字符串的方法:concat()
// System.out.println(str3);
// System.out.println(str1 + str2);
//字符串和字符数组之间的转换
String str4 = "hello"; //字符串转换为字符数组
char[] char1 = str4.toCharArray();
for(int i=0;i<char1.length;i++){
System.out.println(char1[i]);
}
char[] char2 = {'h','e','l','l','o'};
String str5 = new String(char2); //将字符数组作为构造函数的参数
System.out.println(str5);
}
}
public static void main(String[] args) {
/*
//Character字符包装器类
char number = '3';
char letter = 'f';
System.out.println("这些都是字母:" + Character.isLetter(letter)); //true
System.out.println("这些都是数字:" + Character.isDigit(number)); //true
System.out.println("这个字母是大写:" + Character.isUpperCase('A')); //true
System.out.println("这个字母是小写:" + Character.isLowerCase('m')); //true
System.out.println("字母a的返回值大写为:" + Character.toUpperCase('a')); //A
System.out.println("字母A的返回值小写为:" + Character.toLowerCase('A')); //a
System.out.println("字符m的返回String对象为:" + Character.toString('m'));//m
*/
/*
//转义字符
System.out.println("She said \"Hello!\" to me."); //She said "Hello!" to me.
*/
// //获取字符串的长度
// String hello = "大家好,我是张小强!";
// int len = hello.length();
// System.out.println(hello + "的长度是:" + len);
// System.out.println(hello + "的长度是:" + hello.length());
//连接字符串
// String str1 = "hello,";
// String str2 = "my name is Jack!";
// String str3 = str1.concat(str2); //连接字符串的方法:concat()
// System.out.println(str3);
// System.out.println(str1 + str2);
//字符串和字符数组之间的转换
String str4 = "hello"; //字符串转换为字符数组
char[] char1 = str4.toCharArray();
for(int i=0;i<char1.length;i++){
System.out.println(char1[i]);
}
char[] char2 = {'h','e','l','l','o'};
String str5 = new String(char2); //将字符数组作为构造函数的参数
System.out.println(str5);
}
}
0 0
- API 字符与字符串的运用(1)
- 找出A字符串中 B字符串没有的字符(运用java api)
- Delphi 的字符及字符串[5] - 字符串与 Windows API
- 字符串分割 超级简单的api运用 StringTokenizer介绍与实例
- 字符、字符数组(字符串)与指向字符串的指针
- 字符与字符串类型的注意事项(1)
- 进制转换之字符串,字符数组的运用(代码未完全验证)
- 字符与字符串的区别
- Python的字符与字符串
- 字符指针的运用
- 转义字符的运用
- 字符与字符串的表示(ASCII字符,Unicode码,字符串)
- 百度天气api返回json的解析与运用
- HDU 3746 KMP的运用。【求字符串添加几个字符,可以成有循环节字符串】
- 转义字符在字符串中的运用
- 数组线性表ArrayList类(运用与API实现)
- 6174问题(字符串函数的运用)
- 字符串的运用
- 有些人想成功,有些人渴望成功,有些人努力实现成功
- distinct使SQL查询除去重复的字段
- 从mysql中 导出/导入表及数据
- 注册代码
- Apache禁止访问网站子目录的方法
- API 字符与字符串的运用(1)
- 用记事本制表方法
- SQL truncate 、delete与drop区别
- 日期和时间的显示格式的运用(1)
- java定時發郵件
- 2014年2月17日 08:45:55
- 寸阳稍热
- Java 7之传统I/O - InputStreamReader和OutputStreamWriter
- SQL Server 2012 AlwaysOn 异步操作