zoukankan      html  css  js  c++  java
  • 小技巧

    1 js和java中的不定参数

    小案列(js)

    <!doctype html>
    <html>
    <head>
    <script>
        function add(){
            sum=0;
            for( var i=0;i<arguments.length;i++){
                sum=sum+arguments[i];
            }
            return sum;
        }
        alert(add(1,3,5));
    </script>
    </head>
    <body>
    <body>
    </html>
    View Code

    小案列(java)

    public class Test{
        
        public static void main(String[] args){
            show("a","b");
            show("a","b","c");
            show("a","b","c","d");
            show("a","b","c","d","e");
        }
        
        
        public static void show(String...args){
            for(String s: args){
                System.out.print(s+"    ");
            }
            System.out.println();    
        }
    }
    View Code
  • 相关阅读:
    CCS
    CCS
    CCS
    CCS
    CCS
    CCS
    CCS
    CCS
    Java之内部类
    Java之回调模式和ThreadLocal
  • 原文地址:https://www.cnblogs.com/yaobolove/p/4679405.html
Copyright © 2011-2022 走看看