🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
2 messages
2 total messages Started by L Remond Mon, 24 May 2004 12:13
Printing the Values of Class properties
#143
Author: L Remond
Date: Mon, 24 May 2004 12:13
14 lines
1295 bytes
I have a class with about 30 properties and I would like to print the value of them all without using a System.out.println for each one.  I am using the following code to extract the properties from the class but I do not see any methods that wil allow me to print the values of them

    Field[] fields = this.getClass().getDeclaredFields();
     for ( int i=0; i < fields.length; i++ )
     {
        System.out.println(fields[i].getName() + " : values: "  );
     }


Is there a way to do this 


Thanks
Re: Printing the Values of Class properties
#144
Author: Gillmer J. Derge (TeamB)
Date: Mon, 24 May 2004 12:30
13 lines
1572 bytes
L Remond wrote:
> I have a class with about 30 properties and I would like to print the value of them all without using a System.out.println for each one.  I am using the following code to extract the properties from the class but I do not see any methods that wil allow me to print the values of them
> 
>     Field[] fields = this.getClass().getDeclaredFields();
>      for ( int i=0; i < fields.length; i++ )
>      {
>         System.out.println(fields[i].getName() + " : values: "  );

System.out.println(fields[i].getName() + " : values: " + 
fields[i].get(this));

-- 
Gillmer J. Derge (TeamB)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads