This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!

Lampros Marantos

+ Follow
since Dec 02, 2018
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lampros Marantos

Tim Holloway wrote:If you define a variable as being of type Map, the only time that the insert method wouldn't be allowable would be if the value of the variable was null, since no methods can be executed when there's nothing to execute them on.

The mere fact that you declared it as type Map means that anything that gets assigned to that variable has promised (via the "implements" clause of the class definition) to honor each and every one of the methods declared in the Map interface as seen in the official JavaDocs.

Now a specific implementation of Map - say a read-only Map - might implement the "put" method as simply throwing an UnimplementedOperationException, but it's still a "put" method, regardless.

I guessed that i should add an element to the instantiation of Map, but i get the error that the Map collection is null. So how am i able to add an element to such a oollection if the variable is null?  
8 months ago
We are supposed to use our own created structure storage scheme for Notifications.

These are included:

I am instantiating and implementing pair in a class, such as :

For some reason, the same statement in another class gives me error regarding the Type parameters K and T used. (K and T cannot be resolved to a type) What can be the issue?
I am fairly new to generics collections so it might be something simple.  
8 months ago

Paweł Baczyński wrote:

Does it even compile? You are using a variable that is not initialized.

That is the point of the question, i am now allowed to use a HashMap in order to initialize the Map...(and afterwards use Put method to insert an element.)
In such a case, how can i initialize it, so it accepts the insert method?

Thank you.
8 months ago

I am implementing a project in which a number of notifications are stored in a Map<Double, LocNot>, where LocNot is the Type for the notifications.
I am not allowed to use any ready-made data strcuture of Java such an arraylist or a map. There is already a map class, user-defined for that reason, which includes the method:

The method is implemented in a class that implements the Map interface as :

When i am trying to insert a new value from another class, whith the use of insert , i am having an error that the Map used has not been initialized
(i am creating a static content within the class:)

which leads to NullPointerException on behalf of both minimap and notmap. Any ideas, on how i can procceed from this point?
8 months ago
Thank you for the reply and the welcoming!
8 months ago

I am implementing a binary research tree class which impelments the Map interface:

I am not sure how to procceed though, as i am getting an eroor of  "Bound mismatch".

I tried various alterations, but i am always getting the error:
Any help is appreciated!
8 months ago