Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Passing a class name into a method.  RSS feed

 
Ranch Hand
Posts: 90
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 {
 
Sheriff
Posts: 12357
201
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac 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?
 
Author and ninkuma
Marshal
Posts: 66810
168
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: 90
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.
 
author
Sheriff
Posts: 23590
138
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: 66810
168
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: 90
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.
 
Marshal
Posts: 60199
188
  • 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!