public final class Table extends Object
Differs from a 2D Object[][] in that names can be used instead of indices.
All indexes are internally strings. When adding or retrieving values, either numerical and string indices can be specified for either row or col when retrieving a (row,col) value. A numerical index is converted into a string value so if one puts a value at (3, 5), that can later be retrieved as ("3", "5") if desired.
Thread safety: This data structure is fully thread safe.
Constructor and Description |
---|
Table()
Constructs a new table.
|
Table(int rows,
int cols)
Constructs a new table of the specified initial size.
|
Modifier and Type | Method and Description |
---|---|
Object |
get(int row,
int col)
Returns the object at row, col or null if the
specified row or col do not exist.
|
Object |
get(int row,
String col)
Returns the object at row, col or null if the
specified row or col do not exist.
|
Object |
get(String row,
int col)
Returns the object at row, col or null if the
specified row or col do not exist.
|
Object |
get(String row,
String col)
Returns the object at row, col or null if the
specified row or col do not exist.
|
static void |
main(String[] args) |
Object |
put(int row,
int col,
Object obj) |
Object |
put(int row,
String col,
Object obj) |
Object |
put(String row,
int col,
Object obj) |
Object |
put(String row,
String col,
Object obj)
Returns the object at row, col or null if the
specified row or col do not exist.
|
String |
toString() |
public Table()
public Table(int rows, int cols)
public Object get(String row, String col)
public Object get(int row, String col)
public Object get(String row, int col)
public Object get(int row, int col)
public Object put(String row, String col, Object obj)