Results 1 to 6 of 6
  1. #1
    nekt is offline Member
    Join Date
    Feb 2009
    Posts
    1
    Rep Power
    0

    Default Passing Class Reference to method

    Hello People

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

    Here is the sample code from class A
    Java Code:
    public Integer[] getReport(Class classname, String sql) {
    And, then when it is called inside class C, it is referred to as ,
    Java Code:
    new A().getReport(B.class, "select * from Table A")
    where B is another class
    Please give your suggestions on this

    Thanks

    Nek

  2. #2
    piyu.sha is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    This can be used to do runtime type identification. for example

    you can do if class is B.class then do one thing and if class is C.class then do other,

    this can also be used to use reflection based on class methods.
    Live life king size
    [Lucene]

  3. #3
    piyu.sha is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    also check the java.lang.reflection API document for more details on reflection which is a very powerfull API
    Live life king size
    [Lucene]

  4. #4
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    I may not be understanding the problem, but it seems to me you want to define and implement a common interface here rather than using reflection.

  5. #5
    arseny is offline Member
    Join Date
    Mar 2009
    Posts
    25
    Rep Power
    0

    Default

    Please could you explain the target?

  6. #6
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    I don't see anything wrong with what you have, so I'm not really sure what your asking for.

Similar Threads

  1. Replies: 5
    Last Post: 10-04-2008, 11:13 AM
  2. Replies: 29
    Last Post: 09-25-2008, 07:55 PM
  3. Problems passing a scan object to a method
    By xkross in forum New To Java
    Replies: 4
    Last Post: 04-16-2008, 03:56 PM
  4. Replies: 0
    Last Post: 11-10-2007, 04:47 PM
  5. Help passing arraylist to another class
    By adlb1300 in forum New To Java
    Replies: 3
    Last Post: 11-06-2007, 08:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •