Are you asking why checkDay() is a private method? It checks that you've given the constructor a valid day of the month and prints out an error message if you haven't. Nothing is supposed to call that method from outside the class, so they made it private.
Note that in line 9, the method can not only access the name variable of the current object, it can also access the name variable of another Example object (the one that e refers to).
Sometimes new Java programmers are confused by this. I thought that might be your question. If that was not what you were asking about, then please explain exactly what your question is.
Gustavo, I really think you need a better Portuguese-to-English translator. It is impossible for an English-speaker (like me, for example) to understand your questions.
I don't understand what you mean with "the that was done".
In those two lines, two private member variables are declared of type Date. Since you don't initialize them, they will be initialized to the default value which is null.
Hello all!
First want apologize for not informing clearly into doubt.
The question this in that code, see:
Note: I am Brazilian! I am learning English.
Sorry by disorder!
Here code:
I know declaration variable string, int and derivates. But, in that case, no this declaration the variable birthDate how String ou int.
The variable this declared how Date. By which reason ?
Note: I no using the class Date of Java (import java.util.Date).
So, is your question why these variables are of type Date and not String, int or something else?
Well, if you want to store things like a birth date or hire date then the data type Date seems a more appropriate choice to me than String, int or something else.
Variables can be of any type you want, there is no reason why it should always be String or int or something like that.
Java has tons of pre-defined classes. You are not limited to Strings, Integers and Floats. Some day, look at the java API (the java 6.0 API is here).
So, this code uses one of these other pre-defined classes call "Date". You can search that API page and see its constructors and other methods you can call on any Date object.