1· 键盘录入的方法
第一套体系:nextLine() 接收字符串
特点:可以接收空格,制表符,遇到回车才会停止
第二套体系: nextInt()接收整数
nextDouble() 接受小数
next() 接收字符串
特点;遇到制表符,空格和回车停止录入,转到下一个对象。
2· 生成随机数
import java.util.Random;
Random r=new Random();
int i=sc.nextInt(); //根据需要更换类型
3`switch 用法
int a=2;
switch (a){
case 1:
case 2:
case 3:
System.out.println("输出123");
break;
case 4:
System.out.println("输出4");
4·在数组中添加大小写字母方法
char[] chs=new char[52];
for (int i = 0; i < chs.length; i++) {
if(i<=25){
//添加小写字母
chs[i]=(char)(97+i);
}else
{//添加大写字母
chs[i]=(char)(65+i-26);
}
}
5·快捷for循环方法
int arr[]=new int[3];
arr.fori 可实现以下效果
for(int i=0;i<arr.length;i++){