Forums Register Login

Passing a class name into a method.

+Pie Number of slices to send: Send
Im not sure what is happening when i pass the name of the class, and the constructor into a method arg, is the method taking on the the initialization from the constructor, or merely taking the instance variables
(doubt it because those are private) . Could someone shed some light or point me to some reading material.
public class Point {
+Pie Number of slices to send: Send
Not sure where you think that's happening. are you referring to line 10?
+Pie Number of slices to send: Send
It just means that the Distance method -- which should be named distance -- takes a single parameter of an instance of Point.
+Pie Number of slices to send: Send
Yes im referring to line 10.
My bad, naming convention does say that method names start with lower case.
+Pie Number of slices to send: Send
 

rick pine wrote:Yes im referring to line 10.



Line 10 is a method declaration. The method "Distance" takes one parameter, which is a reference to a Point instance.

Not sure what you mean by constructor, as there is no relation -- as it could be any Point instance, that is passed in.

Henry
+Pie Number of slices to send: Send
E.g.

+Pie Number of slices to send: Send
I get it now, thanks for all the replies guys. I know it was kind of a dumb question but i prefer to ask dumb questions than to remain ignorant.
+Pie Number of slices to send: Send
Remember there is no such thing as a question too easy in this forum.
it's a teeny, tiny, wafer thin ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 451 times.
Similar Threads
Question 80 from Java rules round up
getters and setters
Assigning value to Parameters
How to make Date Immutable
coordinate conversion project
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:17:33.