Community
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

cannot find symbol

 
Post new topic   Reply to topic    Community Forum Index -> Java
View previous topic :: View next topic  
Author Message
jon80



Joined: 28 May 2009
Posts: 24

PostPosted: Sun Aug 19, 2012 7:29 am    Post subject: cannot find symbol Reply with quote

Any idea why this won't compile please?

Code:

/**
 * 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
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Community Forum Index -> Java All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB