• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use nested hashmap after reading text file and storing it in nested hashmap

 
Maitrey patel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I want to store data contained in text file(containing double values) into nested hashmap.I have tried to search but not able to get any idea.

here is the code that i am trying. All data i want to store in table like format : outer hashmap stores row index as key,its value will be inner hashmap,than inner hashmap' key is column index and value will be data from file.

But in this code what happens is : for each row it stores value for whole inner hashmap. and what my requirement is to for each row only data for that particular row will be stored.than for next row of text file ,next row data will be stored.


 
Tony Docherty
Saloon Keeper
Posts: 3142
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Please UseCodeTags (← click) when posting code as it makes it easier for people to read your code. I've added them for you this time.


If you want a different inner map for each row then you need to create a new map object for each row. You are using the same map object for the inner map for all rows.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!