随笔 - 64  文章 - 0  评论 - 2  阅读 - 4506

什么是方法?

 

 

复制代码
 1 package method;
 2 
 3 public class Demo01 {
 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     public static int add(int a,int b){
12         return a+b;
13     }
14     //test方法
15      public static void test(){
16          for (int i = 0; i <= 1000 ; i++) {
17              if (i%5==0){
18                  System.out.print(i+"\t");
19              }
20              if (i%(5*3)==0){//每行
21                  System.out.println();
22                  //System.out.print("\n");
23              }
24          }
25      }
26 }
复制代码

 

posted on   一枚努力学习的小白  阅读(24)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示