How to retreive String object name from value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gaya3
    New Member
    • Aug 2007
    • 184

    #1

    How to retreive String object name from value

    Hi,
    How to retreive String Object name from its value in java.?
    in the following example
    String s1="name";
    Thanks in Advance

    -Thanks & Regards
    Hamsa
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Have a look at the getClass() method and the Class.getName() method.

    kind regards,

    Jos

    Comment

    • gaya3
      New Member
      • Aug 2007
      • 184

      #3
      Originally posted by JosAH
      Have a look at the getClass() method and the Class.getName() method.

      kind regards,

      Jos

      yes..Jos.. Class.getName() ll return name of the class.. i ll put you in other way
      I'm having one Java Vo class.In that I'm having fields like "FirstName" and "LastName". Also contains set and get() method for those 2 fields..
      ok? Till this its clear rite..
      Form another Class i'm accessing getlastName() it ll return the "LastName" value rt..
      What i need is both the "LastName" Field value and Field name..(i.e ,LastName).
      You consider like "Field names are unknown to you" only set() and get() methods are known to you..
      you got my point?


      -Thanks & Regards,
      Hamsa

      Comment

      • BigDaddyLH
        Recognized Expert Top Contributor
        • Dec 2007
        • 1216

        #4
        Why do you want to know or need to know the names of fields in a class? Suppose, as is usually the case, the fields are private. What good is it to know the names of the fields in that case?

        Comment

        Working...