Hi all ,

Good Day!

I am having confusion in storing null values in hashmap and passing null in println method.

1) When I add null value in hash map directly it will not allow at the same time when I assign a null value in to string and add that string in to hash map it allows once. how its working.

2) Similarly how null printing when pass null in println method.

Pls clearify me.Thanks in advance.

1) When I add null value in hash map directly it will not allow at the same time when I assign a null value in to string and add that string in to hash map it allows once. how its working.

There shouldn't be a problem adding null value directly to a HashMap variable. How did you declare your variable? What are 2 types you assigned to the HashMap?

2) Similarly how null printing when pass null in println method.

You simply use System.out.println() method. It should display null string as the display.

Edited 2 Years Ago by Taywin

This question has already been answered. Start a new discussion instead.