i have hashmap key integer (represent rows no.) , value array object (has fraction numbers) hashmap<integer,arraylist<number>>
number class has methods calculation on fraction
the user should enter number of rows , columns , enter fraction numbers.
i filled hash map without errors asked retrieve fraction number entering row no. , column no following method:
the class has
public method number getitem(int rowno, int colno)gets , returns specific number item in matrix according given argument. ex.getitem(2, 3)returns1/3.
how can that?
it's similar how fill hashmap data.
as verbose steps
public number getitem(int rowno, int colno) { // data row arraylist<number> row = yourmap.get(rowno); // value of specific column of row number value = row.get(colno); return value; } or shorthand
public number getitem(int rowno, int colno) { return yourmap.get(rowno).get(colno); }