Skip to main content

Question regarding playing cards example.

1 reply [Last post]
ceromus
Offline
Joined: 2008-08-16
Points: 0

In the following code:
http://java.sun.com/docs/books/tutorial/java/javaOO/examples/Deck.java

contained the following sigment:
public Deck() { // Why is this line required?

Why is the Deck() part required? This would be considered the default constructor right? Without it shouldnt the code still be ok? I can see in eclipse that it warns me that the cards = new Card[numSuits][numRanks]; line now requires extra syntax.

What am I missing here? Thanks.

Message was edited by: ceromus

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ceromus
Offline
Joined: 2008-08-16
Points: 0

I got my answer:

You can't have code in the "class scope", only declarations.

I must have missed that part in the tutorial?