Fri Dec 12, 2008 9:56 pm
import java.io.*;
class MyClass {
public void printStuff(String greet, int... values) {
for (int v : values ) {
System.out.println( greet + ":" + v);
}
}
}
class VarargTest {
public static void main(String[] args) {
MyClass mc = new MyClass();
mc.printStuff("Hello", 1);
mc.printStuff("Hey", 1,2);
mc.printStuff("Hey you", 1,2,3);
}
}
/* code taken from apress SCJP 1.5 */
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.