0

So, I'm creating a program that allows users to specify 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.

2
  • You need to provide more information about your problem, I think, in order to get a helpful answer. For example, give specific details about the error you are getting that you don't understand (paste the error message in) or provide code snippets that don't do what you think they should. Commented Sep 15, 2011 at 23:45
  • but its just a little thing not a major code issue. but thanks for trying :) Commented Sep 15, 2011 at 23:52

1 Answer 1

2

Right, that's invalid Java. Try,

Map<String, InsurancePolicy> coverOwnerMap = new HashMap<String, InsurancePolicy>();
Sign up to request clarification or add additional context in comments.

1 Comment

yep, i didnt know about that, there you go green tick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.