zoukankan      html  css  js  c++  java
  • java可变参数的支持和foreach输出

    java特性之-variable parameter(对可变参数的支持),如下:

    public class VariableParameter {
    public static void main(String[] args) {
    fun(1,2,3,4,5);//传入5个参数;
    System.out.println(" ");
    fun(1,2,3);//传入3个参数;
    }
    public static void fun(int...args){
    for(int x:args){
    System.out.print(x+"、");
    }
    }
    }
    格式为:返回值类型 方法名(类型...参数名称),即可以传入个数不定的参数。

    java特性-foreach,方便的输出数组,如下:

    int [] args=int[10];
    for(int x:args){
    System.out.println(x);
    }

  • 相关阅读:
    Vue自定义指令 directive
    Vue过滤器 filters
    贪心
    家庭作业
    线段
    数列极差
    shell
    智力大冲浪
    加工生产调度
    喷水装置
  • 原文地址:https://www.cnblogs.com/CodeMeteor/p/3663140.html
Copyright © 2011-2022 走看看