开发者

How to use a map in java when dealing with objects

So, I'm creating a program that allows users to 开发者_StackOverflowspecify the insurance cover they want as part of an insurance policy. As part of it, I need to use a map in order to track the owner of each specific insurance policy.

I have seen examples of how to use a map with regards to String and int values, but nothing for self made classes (InsurancePolicy in my case).

So, I'm trying to do it like this, but I get the illegal expression warnings:

Map<String, InsurancePolicy> coverOwnerMap<String, InsurancePolicy>();

Any help would be very appreciated.


Right, that's invalid Java. Try,

Map<String, InsurancePolicy> coverOwnerMap = new HashMap<String, InsurancePolicy>();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜