Forums Register Login

Objects and Constructs.

+Pie Number of slices to send: Send
Hi the all!
See code: http://codepaste.net/u6x9vz
I with difficult for understand the question of acess objects of others class.
See here:





Because was given the access private ? And no public ?
Thanks you!
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Hm..Ok. Thanks you!
Now, the that was done here ?

+Pie Number of slices to send: Send
What do you mean with "the that is done here"?

private works per class, not per object. So a method in a class can access the private variables of any instance of the class.
+Pie Number of slices to send: Send
One example please ?
+Pie Number of slices to send: Send
 

Jesper de Jong wrote:What do you mean with "the that is done here"?



I think that's a bad translation from Portuguese, and something like "that which is done here" would be better.
+Pie Number of slices to send: Send
An example of "private works per class":

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.
+Pie Number of slices to send: Send
Hello Jasper!
No is the question.

Here.



The that was done ?
Set itself birthDate of type Date ? How so ?
Thanks you!
1
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.

See Declaring Member Variables in Oracle's Java Tutorials.
+Pie Number of slices to send: Send
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).

Note: Please sorry by my language.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Very good!
Thanks by response!
But, int that case he create the type Date for store the that ?
How do I for store in variable ?
+Pie Number of slices to send: Send
It is hard to understand what exactly you are asking...

birthDate and hireDate are variables. The type of these variables is Date.

What exactly do you find confusing about that? It is not different from other variables that have type String or any other type.
+Pie Number of slices to send: Send
I'll take a stab...

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.
+Pie Number of slices to send: Send
 

fred rosenberger wrote: . . . So, this code uses one of these other pre-defined classes call "Date". . .

There are two classes called Date I think you want this one.
My, my, aren't you a big fella. Here, have a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1027 times.
Similar Threads
help creating mutator
High level language, interfaces and structured programming logic
Custom Date class and Appointment class
toSrting() method
how to test the setter methods
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:21:01.