- 编写程序将 “jdk” 全部变为大写,并输出到屏幕,截取子串”DK” 并输出到屏幕
public class Test4 {
public static void main(String[] args) {
String str = "jdk";
String newStr1 = str.toUpperCase();
System.out.println(""+newStr1);
String newStr2 = newStr1.substring(1,3);
System.out.println(newStr2);
}
}
Console:
JDK
DK
- 编写程序将String类型字符串”test” 变为 “tset”.
public class Test4 {
public static void main(String[] args) {
String str = "test";
System.<

这篇博客介绍了几个使用Java String类进行字符串操作的实例,包括将字符串全部转为大写,截取子串,字符串反转,判断字符串对称性,列出所有子串,以及翻转单词字母顺序。还展示了如何拆分包含键值对的字符串。
最低0.47元/天 解锁文章
1946

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



