@ JSFunction public static Object varargs ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( "this = " ) ; buf . append ( Context . toString ( thisObj ) ) ; buf . append ( "; args = [" ) ; for ( int i = 0 ; i < args . length ; i ++ ) { buf . append ( Context . toString ( args [ i ] ) ) ; if ( i + 1 != args . length ) buf . append ( ", " ) ; } buf . append ( "]" ) ; return buf . toString ( ) ; }
An example of a variable - arguments method .