Hi guys, got a few questions

1. i have initialised my collection with a few objects, how do i set the make etc when i initialise them (i have the set methods). So in the line below where would i put setMake()? would it work with a . accesor after LargePlane?

planesAvailable.put("502146", new LargePlane());

2. Im also having a problem with when i create and put objects in the collection i use the key (above 502146) which is the registration of the object how can i set that to the registration within the collection? (when i print out the collection the registration is null).

3. Also I have overided toString(), i have a bunch of types (eg. LargePlane, SmallPlane) that could be in this collection, how do i print like LargePlane? I've tried like typeOf() and stuff but it doesn't work, do i need to import something?

Thanks

Oh ps ignore the first one, i was just curious if i could do it implicitly in that line using the key.

Im also having a problem with when i create and put objects in the collection i use the key (above 502146) which is the registration of the object how can i set that to the registration within the collection? (when i print out the collection the registration is null).

You could use .keySet().toArray() and print out everything in the array it returns. You could also use .containsKey("registrationNumber") to see if the registration number is in the "Collection" (actually since you're using put to map key->value it is probably more specifically some kind of class that extends Map).

Also I have overided toString(), i have a bunch of types (eg. LargePlane, SmallPlane) that could be in this collection, how do i print like LargePlane? I've tried like typeOf() and stuff but it doesn't work, do i need to import something?

System.out.println(yourObject.toString()); I think you already know that, but I don't understand your question.

Be a part of the DaniWeb community

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