• Post Reply Bookmark Topic Watch Topic
  • New Topic

method cannot be applied  RSS feed

 
chavez james
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Thank you for reading my post, i appreciate any help given, i am not seeking answers just advice or help with my program.

Here is my code:



I am using netbeans and getting errors for display(); and size(); it is telling me the errors are : for the display error, "method display in class DebugSix cannot be applied to given types;
display();" and for the size() is : "cannot find symbol System.out.println("\nThe size of the list is " + size());" Please help.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In line 19 you are calling the display method, but you are not supplying it with any arguments. The method expects one argument, an ArrayList. you should pass it an ArrayList, just like you are doing in line 9.

In line 26 you are calling the size() method, but your class DebugSix does not have a size() method. I guess you wanted to call this method in the list: products.size() instead of just size().

You are not using generics consistently. Sometimes you are writing ArrayList<String> (line 4) and sometimes you are using the raw type ArrayList, without the generics (lines 4, 24). The compiler will give you warnings about the raw types.

There's also a bug in line 27. When you get the program to compile without errors, you will get an IndexOutOfBoundsException in line 28 when you try to run it.
 
chavez james
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How could i fix the bug you are talking about?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pretend that there is one item in the list. Walk through what that code would do. What happens?
 
chavez james
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay thank you
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!