• Post Reply Bookmark Topic Watch Topic
  • New Topic

<identifier> expected  RSS feed

 
Angel Kal
Greenhorn
Posts: 17
Chrome Netbeans IDE Windows Vista
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first class dealing with queues, after all this is for Java 2 class. I keep trying to find out why Im getting the identifier expected error, and no such luck after tinkering for days...anyone able to catch it for me? Im sure its something silly but, staring at it for so long seems to be making it harder to find.
Thanks in advance :-)

ERRORS ARE:

NoDuplicatesQueueInterface.java:11: error: <identifier> expected
public NoDupQueueInterface<T>()
^
NoDuplicatesQueueInterface.java:16: error: <identifier> expected
public NoDupQueueInterface<T>(int initialCapacity)
^

2 errors
CODE

 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, let's start with the fundamentals.

a) Firstly, what is the difference between a class and an interface?

a) Could you tell me what is a constructor, when do you write a constructor?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm surprised you didn't get other errors first:


That shouldn't compile. All member variables in an interface are implicitly public static final. Trying to declare them otherwise is an error, as far as I know.

As for the lines you mentioned, you can't have constructors in an interface.

And there will be other problems too. You can't have concrete methods in an interface. All methods in an interface are abstract.
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was waiting for him to come up with all this Jeff. You gave it away too easily.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!