当前位置:   article > 正文

day07 静态方法_编写程序实现静态方法copyimage(string img, string path)

编写程序实现静态方法copyimage(string img, string path)

1. 方法的概念

用来解决特定的问题(实现特定的功能)的一段代码,可以反复使用。

2.定义语法

public static void 方法名称( ){ //方法主体 }

3. 定义位置

与main方法平级

4.调用

在需要调用方法的位置,直接书写方法名();即可实现调用

代码执行到调用方法的位置,会先执行方法内部的代码,再接着执行后续的代码

  1. package com.qfedu.test1;
  2. /**
  3. * 以两种 方式打印诗句 每句诗以后有十个横线
  4. * @author WHD
  5. *
  6. */
  7. public class Test1 {
  8. public static void main(String[] args) {
  9. System.out.println("窗前明月光");
  10. System.out.println("----------");
  11. System.out.println("疑是地上霜");
  12. System.out.println("----------");
  13. System.out.println("举头望明月");
  14. for(int i =1;i <= 10;i++) {
  15. System.out.print("-");
  16. }
  17. System.out.println();
  18. System.out.println("低头思故乡");
  19. for(int i =1;i <= 10;i++) {
  20. System.out.print("-");
  21. }
  22. System.out.println();
  23. }
  24. }
  1. package com.qfedu.test1;
  2. /**
  3. * 使用方法实现 横线 的打印
  4. * 方法的概念:用来解决特定的问题(实现特定的功能)的一段代码,可以反复使用。
  5. * 定义语法:public static void 方法名称(){ // 方法体}
  6. * 定义位置:与main方法平级
  7. *
  8. * @author WHD
  9. *
  10. */
  11. public class Test2 {
  12. public static void main(String[] args) {
  13. System.out.println("窗前明月光");
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/325085
推荐阅读
相关标签
  

闽ICP备14008679号