2020
10-08
10-08
Java语法糖之个数可变的形参的实现
1.背景从JDK1.5开始,Java支持个数可变的形参,类似:publicclassParamDemo{publicstaticvoidmain(String[]args){Stringbasketball="篮球";Stringfootball="足球";showSports(basketball,football);}/***使用个数可变形参的方法*/publicstaticvoidshowSports(String...sports){for(Stringsport:sports){System.out.println(sport);}}}2.优点其实个数可变形参的本质就是一位数组,但是如...
继续阅读 >