java - What does the points stand for? -
this question has answer here:
when write constructor in java this:
import java.io.ioexception; import java.io.outputstream; public class multioutputstream extends outputstream{ outputstream[] ostream; public multioutputstream(outputstream ostream) { this.ostream = ostream; // todo auto-generated constructor stub } @override public void write(int arg0) throws ioexception { // todo auto-generated method stub } }
eclipse says: type mismatch: cannot convert outputstream outputstream[]. eclipse corrected constructor this:
import java.io.ioexception; import java.io.outputstream; public class multioutputstream extends outputstream{ outputstream[] ostream; public multioutputstream(outputstream... ostream) { this.ostream = ostream; // todo auto-generated constructor stub } @override public void write(int arg0) throws ioexception { // todo auto-generated method stub } }
what these points stand for?
thanks in advance!
they called "varargs", see http://docs.oracle.com/javase/7/docs/technotes/guides/language/varargs.html.
the 3 periods after final parameter's type indicate final argument may passed array or sequence of arguments.
Comments
Post a Comment