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.

Recommended Answers

All 2 Replies

Can you provide some code that demonstrates the effect you are asking about?

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.

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.