package com.wys.java; /** * About variable parameter lists, and overloading * @author snape * @version 1.0 * * / Public class ArgsDemo2 { // variable method where the parameter list is the last to be visited // The method with variable parameters public int PLUS ( int n-, int m) { System.out.println ( "without method is called the variable parameter" ); return m + n-; } // The method with variable parameters is not public int PLUS ( int ... n-) { int SUM = 0 ; for ( int I: n-) { sum += i; } System.out.println ( "method with variable parameters is called" ); return SUM; } // test public void testDemo () { System.out.println ( "and as:" + PLUS (5,9 )); } public static void main(String[] args) { ArgsDemo2 argsDemo2 = new ArgsDemo2(); argsDemo2.testDemo (); } }
result: