MayNotBe
MayNotBe

Reputation: 2140

Eclipse wants class in constructor?

Ok, forget it. Just realized I forgot the brackets.

Good lord. I need a rest.

I'm designing my own double linked list.

public class DoubleLinkedList {

    public DoubleLinkedList {

    }

}

That's the extent of my code so far. Eclipse is underlining the public in the constructor and telling me:

"Syntax error on token "public", class expected after this token"

It's a constructor, why is this happening?

Upvotes: 0

Views: 59

Answers (3)

Nambi
Nambi

Reputation: 12042

Constructor must have the parenthesis ().

Do like this:

public class DoubleLinkedList {
    public DoubleLinkedList() {

    }

}

Upvotes: 2

Vivek Vermani
Vivek Vermani

Reputation: 2014

Make it like this

public DoubleLinkedList() {


}

Upvotes: 0

rgettman
rgettman

Reputation: 178303

You missed the () on your constructor. Try

public DoubleLinkedList() {
}

Otherwise it's either a bad class definition or a bad variable definition, and Eclipse must have assumed the former.

Upvotes: 1

Related Questions