Bookmark Topic Watch Topic
  • New Topic

Syntax Error  RSS feed

 
Laura Balsamo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi there. I've coded myself into a hole and I have no idea how to get out of it.

I keep getting a "Syntax error on token, Expression expected" error on

and

. The full method follows:




Any help would be appreciated.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Report post to moderator
What is Entry<K, V> supposed to mean? If you're trying to create an instance of Entry, you need a "new" statement.
 
Laura Balsamo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Fixed. Thanks.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Report post to moderator
Laura Balsamo wrote:public class Entry<K,V> implements java.util.Map.Entry<K, V>

This is supposed to be a Linked List based implementation of the Map class. I'm creating the put() method and trying to pass the K, V values into the linked list cont. However, I am getting this error message. Using the new operator tells me it's not applicable for the method.


The set method is going to be expecting an object as an argument. I don't know what type - you haven't posted that part of the code - but Entry<K, V> is a class name, not an object. You can't use it like that, any more than you can say System.out.println(String) instead of System.out.println("Hello"). Shouldn't it be taking an instance of the class? In which case, you need to create that instance.

When you say you've tried using "new" - how did you try and use it?

Edit: Please don't delete messages after they've been replied to.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Report post to moderator
Laura Balsamo, do not delete posts which have been replied to. That makes the discussion look like nonsense.

Fortunately in this instance it has been possible to reinstate the original post.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!