cannot find symbol

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
jon80
Posts: 24
Joined: Thu May 28, 2009 10:03 am

cannot find symbol

Post by jon80 »

Any idea why this won't compile please?

Code: Select all

/**
 * Java Program which tries to implement variable argument method using
 * method overloading. This started get clumsy once number of parameter exceeds
 * five.
 */
class  VarargsExample{

  /*
   * @return multiplication of all numbers in array
   */
  public int multiply(int[] numbers){
    int result = 1;

    for(int number: numbers){
      result= result*number;
    }

    return result;
  }
}

public class VarargsExampleTest
{
	public static void main (String... args)
	{
		int[] a = new int[] {1,3,2,4,5};
		VarargsExample v = new VarargsExample();
		int[] results = new int[5];
		for (int i = 0;  i < results.length; i++)
		{results[i] = v.multiply[a];}
		for (int i = 0;  i < results.length; i++)
		{System.out.println(results[i]);}
	}
}
/*
Read more: http://javarevisited.blogspot.com/2011/09/variable-argument-in-java5-varargs.html#ixzz23yTFsnIG
*/
Jon
Post Reply