Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot be applied to given types

 
Tom Cummings
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




System.out.println ("\n\nThe Average of integer values is:\t" + mylists.average(integerList)); This part gives me this error: MyList12 cannot be applied to given type and I'm not sure why.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
Tom Cummings wrote: . . .
System.out.println ("\n\nThe Average of integer values is:\t" + mylists.average(integerList)); This part gives me this error: MyList12 cannot be applied to given type and I'm not sure why.
Your integer list is a List of some sort and the method seems to take an int[] as a parameter. You need to ensure that you call the methods with the right arguments. You may wish to overload that method to take the list.
Your indenting is peculiar: it is usual to indent else ifs like thisAlso use spaces, not tabs for indenting.
Avoid numbers: classes like MyLists12 (whose spelling varies in your post) are confusing because you can’t always remember the difference from MyLists11.
Avoid use of the \n character unless you specifically want LF; use the %n tag instead.
 
Winston Gutkowski
Bartender
Pie
Posts: 10273
60
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Cummings wrote:System.out.println ("\n\nThe Average of integer values is:\t" + mylists.average(integerList)); This part gives me this error: MyList12 cannot be applied to given type and I'm not sure why.

Neither are we unless you can tell us where this error is occurring.

However, the whole class seems a bit tortuous. From its fields, I would assume that it defines a List element, but then you have a pile of methods that appear to be based on Lists.

My suggestion: back up a bit and write down what you want, NOT how you want to do it. And just off the top of my head, a Student class (or something like it) sounds to me like a pre-requisite.

Winston

PS: I broke up that enormous line. Please re-read the UseCodeTags page for details.
Also, your populateLists() method is awful. Dealing with that many parameters (most of them Lists) is likely to be an absolute nightmare.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic