什么是方法
package com.menthod;
/*
修饰符 返回值类型 方法名(参水类型:参数值){
方法体
return 返回值;
}
修饰符:public static final等等
返回值类型:int void float 等等
等等等
参数类型:形参:用来定义作用的
实参:实际调用传递的值
*/
public class Demo01 {
//main方法
public static void main(String[] args) {
int sum = add(1,2);
System.out.println(sum);
test01();//这里调用第二个方法
}
//自己定义的加法
// 修饰符 返回值类型 方法名(参数类型 参数值)
public static int add(int a,int b){
return a+b;//方法体
}
//自己定义的一个测试方法
public static void test01() {
for (int i = 0; i < 1000; i++) {
if (i % 5 == 0) {
System.out.print(i + "\t");
}
if (i % (5 * 3) == 0) {
System.out.println();
}
}
}
}