• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing a class name into a method.

 
rick pine
Ranch Hand
Posts: 68
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 {
 
Junilu Lacar
Sheriff
Posts: 9355
96
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure where you think that's happening. are you referring to line 10?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65419
100
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It just means that the Distance method -- which should be named distance -- takes a single parameter of an instance of Point.
 
rick pine
Ranch Hand
Posts: 68
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes im referring to line 10.
My bad, naming convention does say that method names start with lower case.
 
Henry Wong
author
Marshal
Posts: 22365
102
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65419
100
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E.g.

 
rick pine
Ranch Hand
Posts: 68
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 52055
90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember there is no such thing as a question too easy in this forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!