package method;
public class Demo01 {
public static void main(String[] args) {
//main方法
//加法
int sum = add(1, 2);
System.out.println(sum);
//test方法
test();
//test02方法
test02();
}
//------------------------------------------------------------------------------------
//test方法 用 while 或 for 循环输出 1-1000 之间能被 5 整除的数,并且每行三个
public static void test() {
for (int i = 0; i < 1000; i++) {
if (i % 5 == 0) {
System.out.print(i + "\t"); //print 输出完会换行
} //println 输出完不会换行
if (i % (3 * 5) == 0) {
System.out.println("");
}
}
}
//------------------------------------------------------------------------------------
//加法
public static int add(int a,int b){
return a+b;
}
//------------------------------------------------------------------------------------
//test02方法 打印九九乘法表
public static void test02(){
for (int j = 1; j <= 9; j++) {
for (int i = 1; i <= j; i++) {
System.out.print(i + "*" + j + "=" + (j * i)+"\t");
}
System.out.println();
}
}
}
原文:https://www.cnblogs.com/bizhenghe/p/13942447.html