The method clear() is undefined for the type ShoppingCart

后端 未结 3 1633
南方客
南方客 2021-01-13 16:25

I am implementing a shopping website through JSP. I have a Java object called ShoppingCart and one called Item. In ShoppingCart there is a vector w

相关标签:
3条回答
  • 2021-01-13 17:01

    I was just fighting a very similar problem in Eclipse. I deselected "Project->Build Automatically" option and I was clicking "Project->Clean" and cleaning the project, but the error wouldn't go away. Finally, in the dialog that pops up after clicking "Project->Clean", I deselected the "Start a build immediately" option and did a clean.

    It then FINALLY "really" cleaned the project and cleared the error. Then I started a build and all was fine.

    At one point I had commented out the offending line and saved, and Eclipse was still reporting the error on that line!!! I don't know if this is an Eclipse bug or an underlying tool chain bug, but it's definitely not doing the write thing.

    This was with Eclipse Helios Service Release 2 and a Java SE 6 target. Running under Windows XP.

    0 讨论(0)
  • 2021-01-13 17:13

    If that method was newly added and you get this error, you're apparently still using an old version of the class lacking the method in the classpath. You need to save the source code file, recompile/rebuild the class/project, redeploy the project and restart the server to get the new changes to work.

    A bit decent IDE with a bit decent server plugin will do that automagically by the way.

    0 讨论(0)
  • 2021-01-13 17:13

    Try (re)compiling the code, deploying it to the server and then opening your .jsp page. And do it every time you make changes in java code, not html code.

    Java is not interpreted language, but a compiled programming language, whose programs are converted into an executable form before being executed.

    0 讨论(0)
提交回复
热议问题