Java_无参数无返回类型方法及练习


无参数无返回类型方法语法格式:

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

 

 1 class Method03{  2     /*练习3:输出1-100中的每个数,要求使用无参无返回类型的方法完成  3  无参数无返回类型 语法格式:  4  public static void 方法名称(){  5  方法体  6  }  7     */
 8     public static void print(){  9         for(int i = 1; i <= 100; i++){ 10  System.out.println(i); 11  } 12  } 13 } 14 class Method04{ 15     public static void main(String[ ]args){ 16         Method03.print();        //调用Method03
17  } 18 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM