Call Constructor ... name provided as string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    Call Constructor ... name provided as string

    i know ... how to call a constructor as the constructor name is provided as a string....

    but if the constructor is array parameterized ... then how can i do call that constructor.... as we use Integer.TYPE if the constructor is integer parameterized

    i think u got my point

    plz hellllppppppp.. ...thanxxxxx
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    I don't know whether or not I understood your question correctly, but have a look
    at the Class.getConstr uctor() method and the Constructor class.

    kind regards,

    Jos

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      sooryyyyy for wrong Q......

      actuallyy ... i want to get a particular constructor which is array parameterized .....

      i mean ......

      suppose i have String class and it has a constructor like ....
      String(byte br[]) then how can i get the constructor ....
      after doing ...

      Class str_cls = Class.forName(' java.lang.Strin g');
      Constructor str_cns = str_cls.getCons tructor(Class param_types[])

      here what should i pass ....

      plz help .....

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Ah, ok, I think I understand your question now. For a byte array the
        corresponding class object simply is byte[].class and for a T[] the
        corrsesponding class is T[].class etc. etc.

        kind regards,

        Jos

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          thanxxxx a lotttttt

          Comment

          Working...