File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Syntax Error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Syntax Error

Laura Balsamo
Greenhorn

Joined: Oct 16, 2011
Posts: 3
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

Joined: Apr 06, 2010
Posts: 2688

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

Joined: Oct 16, 2011
Posts: 3
Fixed. Thanks.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 2688

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
Sheriff

Joined: Oct 13, 2005
Posts: 26720
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.
 
 
subject: Syntax Error
 
Threads others viewed
Working with HashMap
Is HashMap.put() atomic?
Duplicates in HashSet
priority queue based on unsorted list(Java's LinkedList Class)
How does set ensures uniqueness
developer file tools