学习了static静态方法,静态变量的一些知识,简单的进行一些总结:学习
静态方法无参数且无返回值的方法spa
静态方法有参数无返回值的方法input
静态方法有返回值的方法it
静态方法中无返回值的定义在void,使用void定义的方法都不带返回值,且方法名后()内不带参数变量
static void input(){ //定义一个input方法不带返回值,不带参数引用
Scanner scanner= new Scanner(System.in);方法
System.out.print("姓名:");总结
name=scanner.next(); next
System.out.print("性别:");static
sex=scanner.next().charAt(0);
System.out.println("年龄:");
age=scanner.nextShort();
System.out.println("身高");
height=scanner.nextFloat();
System.out.println("性格:");
type=scanner.next();
}
2
静态方法中无返回值的定义在void,使用void定义的方法都不带返回值,且方法名后()内带参数
private static void feeling(String cause , String content) { //使用参数,有两个参数,表明两种的状态
System.out.println(cause);
System.out.println(content);
feeling(“心情不错”,“中了500万的缘故”) //在别的方法内进行引用
3带参数和返回值的方法,简单的例子在于计算类型,输入2个数字,计算结果的方法
static int math(int a,int b){
return
}
先简单的作个记录