package Demo_1_22_String; public class StringDemo { public static void main(String[] args) { String str = "www.baidu.com"; char c = str.charAt(4); // charAt()获取索引所在的字符 System.out.println("char c = " + c); //将str的字母变为大写 // 将字符串变为字符数组 char [] result = str.toCharArray(); for (int i = 0; i < result.length; i++) { if (result[i] == '.') { }else { result[i] -= 32; // 编码表的位置向前移动32位 } } String newStr = new String(result); // 将字符数组变为字符串 System.out.println(newStr); char a = '1'; System.out.println(a); } }