• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to print ArrayList values?  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,
I'm having ArrayList collection. That ArrayList contains Employee object. The Employee object contains Id, Name, Dept, DOJ, Address properties.
I have to print this ArrayList in a table format.

Could anyone please tell me how to display the print dialogue box and print the ArrayList values in table format?




Thanks in advance,
Shans
 
Marshal
Posts: 57238
175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you mean by printing? On paper or on the command/terminal window?

What does toString() in Employee return?
Can you write a prettyPrintToString() or even a void prettyPrint() method in the Employee class? Then you could iterate through your List and call a pretty-printing method on each included Object.
 
Shans sat
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really mean to printing on a paper.
 
Sheriff
Posts: 21201
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A lazy way is to create a JTable, fill it with your objects, then print that. JTable has some nice methods for printing.
 
Shans sat
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For that I used print() method to print the table values (on paper).




But, the time taken for displaying print dialouge box so late and printing operation is done very slowly.

Could anyone please tell me is there any better way and fastest way to print the table values?
 
I'm so happy! And I wish to make this tiny ad happy too:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!