- import java.util.Scanner;
- public class Examption01 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("请输入一串字符");
- String s = sc.nextLine();
- char[] arr = s.toCharArray();
- for (int i= 0;i<arr.length;i++) {
- char c = arr[i];
- if (c>='a'&c<='z') {
- char b = (char)(c-32);
- System.out.println("您输入小写字符对应的大写字符为"+b);
- }
- else if(c>='A' & c<='Z') {
- char g = (char)(c+32);
- System.out.println("您输入的大写字符对应的小写字符为"+g);
- }
- else {
- System.out.println("大哥,字符,字符,字符,看不懂啊。再来------"+"\n");
- }
- }
- }
- }
复制代码
|
|