• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing Class Reference to method

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello People

Please suggest me the use of passing class reference in a method

Here is the sample code from class A


And, then when it is called inside class C, it is referred to as ,


where B is another class



Please give your suggestions on this

Thanks

Nek
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please give your suggestions on this



You want us to guess on what your code does? And why it needs a class object?

Henry
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:You want us to guess on what your code does? And why it needs a class object?


I think it's more a case of they want someone to do their homework for them. This question has been posted on other Java forums.
 
Marshal
Posts: 79406
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Tony, for noticing that. Please, Nek Thomas, look at this FAQ.
 
nek thomas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply

Yes, I did post to other forums first, but after not getting suitable response I decided to post on javaranch



Please give your suggestions on this topic about use of Class Object in this particular example
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please give your suggestions on this topic about use of Class Object in this particular example



I don't get it. It's your code. Why don't you tell us why you need to do SQL on a Java class?

If I had to guess, maybe something related to reflection needs to be done, and it also needs some data from a DB?

Henry
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nek, you can pass a Class object to a method, there's no problem with that.
Your example is correct provided you know what you're doing.

What is your question?
 
nek thomas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your suggestions

I have questions about the use of passing .class as a reference anywhere. And, please give suggestions of usage of .class in java code


 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a couple of articles on reflection on java.sun.com:
  • Reflection API Tutorial
  • Advanced Language Topics: Using Java Reflection

  • They both have sample code using class objects.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic