This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

is there any table like data structure in java ?  RSS feed

 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
thank you for reading my post
I am looking for a table like (rows and columns) data structure in java
does standard java has such thing or we should use some 3rd party libraries.

something lik :

columnA ColumnB ...
aaa dddd ...
bbb eeee ...
ccc gggg ...
 
Jeff Storey
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are looking for a visualization of a table, consider using a JTable. If you are looking for only a data sturcture, you can just make a 2-d array:

int[][] myTable = new int[5][5];

This would give you a table of all integers with 5 rows and 5 columns. You could do this with any data type, not just ints.

Jeff
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HashMap
Hashtable

I guess it depends on what you're trying to do.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HashMap and Hashtable are dictionary data structures; I don't think that is what Raminaa is looking for.

There is no general purpose data structure in the standard Java API for a table-like data structure with columns and rows. However, you could use class javax.swing.table.DefaultTableModel. It's a Swing class but that doesn't mean you can only use it in programs with a Swing user interface.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!