什么是方法?

 1 package com.pingfan.method;
 2 
 3 public class Demo1 {
 4     //main方法
 5     public static void main(String[] args) {
 6         //int sum = add(1,2);
 7         // System.out.println(sum);
 8         test();
 9     }
10 
11 
12 
13     //加法
14     public static int add(int a,int b){
15         return a+b;
16     }
17 
18     public static void test(){
19         for (int i = 1; i <= 1000; i++) {
20             if(i%5==0){
21                 System.out.print(i + "\t");
22             }
23             if (i%(5*3)==0){//每行
24                 System.out.println();
25                 //System.out.print("\n");
26             }
27         }
28     }
29 }

 

posted @ 2021-03-23 17:26  HeartlessHero  阅读(50)  评论(0)    收藏  举报