Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

converting an object into an String array

807580Nov 7 2009 — edited Nov 9 2009
Hi friends,

I have defined one class
  public class UserRegistration {
    String first_name = null;
    String last_name = null;
    String dobd = null;
    String dobm = null;
    String doby = null;
    String gender = null;
    String occupation = null;
    String marital_status = null;


public String getFirst_name()
    {
       return this.first_name;
    }
   public String getLast_name()
    {
       return this.last_name;
    }
   public String getDobd()
    {
       return this.dobd;
    }
   public String getDobm()
    {
       return this.dobm;
    }
   public String getDoby()
    {
       return this.doby;
    }
 
   ..................
   ....................
} 
and I have instantiated this class in a different class but so far I can access fields of UserRegistration class like this way
UserRegistration object = new UserRegistration();

String str = object.first_name;

It shows that I cant use this object as an aaray like
String str = object[0] ;

My intention is to use this UserRegistration's object as an array so that I can iterate through its fields using a loop not by using its fields name and a dot operator manually.

How to convert this object to and String array?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 7 2009
Added on Nov 7 2009
4 comments
231 views