PAT乙级刷题经验(持续更)

1.多种数据类型组合时输入可以用字符串数组;
2.关于int与String类型的转换
int -> String
int i=12345;
String s="";

第一种方法:s=i+"";
第二种方法:s=String.valueOf(i);

String -> int
s=“12345”;
int i;
第一种方法:i=Integer.parseInt(s);
第二种方法:i=Integer.valueOf(s).intValue();
3.使用IO类BufferedReader、InputStreamReader、IOException输入;
4.String str1 = str.split(" “);split函数可将字符串按空格分割,并且填充到字符串数组中;
eg:
String s = “Let’s go for lunch!”;
String[] as = s.split(” ");

猜你喜欢

转载自blog.csdn.net/weixin_43028756/article/details/89921777
今日推荐