Hi all,

I have some data in the file, which I want to store in the following format :

23 345 9.8
25 457 9.0
11 237 8.3
86 32 2.3
and so on.....

I want to store this data in in some data structure, and later I want to sort it based on the last item (i.e. third attribute 9.8/9.0 etc)

I was trying something like "List <Integer,Integer, Double>" but it does not work..

there can be duplicate rows, so there can not be a key/value etc.

what are the other alternatives I have in Java 1.7?? Any suggestions welcome...

Thank You.

Recommended Answers

Please don't ask us to do your homework for you! Make an attempt to code this to the best of your ability and we will be happy to help you with your mistakes.

Jump to Post

All 2 Replies

Please don't ask us to do your homework for you! Make an attempt to code this to the best of your ability and we will be happy to help you with your mistakes.

One possibility is a list where each element is a list of 3 numbers, but it looks like each line represents a single "something", so one obvious approach would be to create a "Something" class to encapsulate those 3 values, and have a List<Something>. That also puts you in a good position to start sorting your Somethings by implementing Comparable in the Something class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.