Why isn't the "this." command needed in this constructor? (java)

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-03-22T18:35:54Z Indexed on 2010/03/22 18:41 UTC
Read the original article Hit count: 274

Filed under:
|
|
|

I'm reading a book about java. It just got to explaining how you create a class called "deck" which contains an array of cards as its instance variable(s). Here is the code snippit:

class Deck { 
Card[] cards; 
public Deck (int n) { 
cards = new Card[n]; 
} 
} 

why isn't the this. command used?

for example why isn't the code this:

class Deck { 
Card[[] cards; 
public Deck (int n) { 
this.cards = new Card[n];
}
}

© Stack Overflow or respective owner

Related posts about java

Related posts about constructor