Calculating multiple car prices from a file
Your ArrayList and HashMap declarations are missing type arguments. Assuming if you're developing on Java 7 then all you're missing is just the diamond operator, e.g. ArrayList&lt;&gt;().

Company t = new Company();
t.setName("Benz");
t.setPrice(10000);
trn.add(t);
t = null;
t = new Company();
t.setName("BMW");
t.setPrice(3000);
trn.add(t);
t = null;
t = new Company();
t.setName("Benz");
t.setPrice(1000);
trn.add(t);
t = null;
t = new Company();
t.setName("Toyota");
t.setPrice(500);
trn.add(t);


This is an odd way of adding four objects into your List. Assuming if your Company object has the following simple constructor, you should do it as such:

trn.add(new Company("Benz", 10000));
trn.add(new Company("BMW", 3000));
trn.add(new Company("Benz", 1000));
trn.add(new Company("Toyota", 500));


Instead of a nested for loop and skipping entries that already exist in the result map, you can consider retrieving the existing calculated sum from the map, if any, and add the current price to that. Also, why is map created as Map&lt;String, String&gt; and not Map&lt;String, Integer&gt; or Map&lt;Company, Integer&gt;?

One more thing, you can consider putting this particular comparison as a method in your Company class: com.getName().equalsIgnoreCase(name).