Loop thru coustomers, loop thru each customer's repairs looking for the right key value, eg
for (Customer c : customers) {
for (String repairNo : c.getRepairs().keySet()) {
if (repairNo.equals(...)) ... Repair r = c.getRepairs().get(repairNo)
(this code can be optimised, but that's the clearest version to understand)
JamesCherrill
... trying to help
8,512 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,455
Skill Endorsements: 30
Is map a map, list, collection, array filled with (only) objects of the type Customer?
stultuske
Industrious Poster
4,371 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
a Map exists out of an Object and a Key, you are treating it as a list or array which has only the Object as element.
that's your problem.
stultuske
Industrious Poster
4,371 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
I was illustrating the way to solve your problem, not giving actual complete code. You just need to loop through all your Customers, and given your Map you will find those in map.values()
ps When I used ... on line 3, that's not real Java syntax :-)
JamesCherrill
... trying to help
8,512 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,455
Skill Endorsements: 30
Can you post the definition for the aMap variable.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Can you post the definition of aMap.
A definition has the datatype followed by the variable name. The first 3 lines of your post define the variables: file, f and s. aMap is not defined, It is assigned a value.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
The definition of aMap (Map aMap) is without any type and defaults to Object. That's why the compiler says:
found: java.lang.Object"
Give it a definition:
Map<K, V> aMap
with the correct types for K and V
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Question Answered as of 10 Months Ago by
NormR1,
stultuske
and
JamesCherrill