import java.util.Scanner;
public class test1 {
public static void main(String[] args) {
ff3(); // 只调用ff3()方法
}
//输出字符串
public static void ff() {
String sstring = "你是一个好男人!";
System.out.println(sstring);
}
//字符串转换成数组,,输出数组和ASCLL
public static void ff1() {
String sstring = "you are a good man";
char cc[] = sstring.toCharArray();
for (int i = 0; i < cc.length; i++) {
System.out.println(cc[i] + " " + (int) (cc[i]));
}
}
//接收键盘数据,输出数组和ASCLL
public static void ff2() {
Scanner sscScanner = new Scanner(System.in);
String sstrString = sscScanner.next();
System.out.println(sstrString);
}
// 接收键盘输入 的字符串,转换成数组,输出ASCLL
public static void ff3() {
System.out.println("输入需要转换的字符串");
Scanner sscScanner1 = new Scanner(System.in);
String sstrString1 = sscScanner1.next();
char cchar[] = sstrString1.toCharArray();
for (int i = 0; i < cchar.length; i++) {
System.out.println(cchar[i]+"-->"+(int)cchar[i]);
}
}
}
Java 对字符以及字符数组的操作
最新推荐文章于 2023-09-23 22:50:17 发布