4
Contributors
14
Replies
67
Views
9 Months
Discussion Span
Last Post by JamesCherrill
Featured Replies
  • Yes, Java always passes parameters by value. But sorry, your question is not clear. Please explain exactly what you want to know. Read More

  • 1

    Under the covers, all Java objects are references. When you assign one variable to another, the reference is copied, not the object's data. At that point, both variables hold a valid reference to the the object and the actual object data cannot be garbage-collected until both variables are cleared (set … Read More

  • We are all guilty of speaking a kind of shorthand about objects and variables. Most of the time it's OK, but when we talk of call by value etc it really matters. An object is an object. A variable is not an object and an object is not a variable. … Read More

  • >I just want to start in right way how to start by giving my giving effort Excellent. Glad you want to show efffort and start off on the right foot. However, your posts are coming off as a bit demanding and vague. Not saying that was your INTENT. Just saying … Read More

  • 1

    You'll do ok Kasis if you remember that you can find most of your answers on the Internet. Post here when you are totally bumfuzzled (confused). We will be happy to help then. FWIW, a map is a collection of key/value pairs that is indexed on the key. A hash-map … Read More

0

Can u explain
Changes are reflected back if we do not assign reference to a new location or object:
Illustrate this!

Edited by kasis

1

Yes, Java always passes parameters by value.
But sorry, your question is not clear. Please explain exactly what you want to know.

1

Under the covers, all Java objects are references. When you assign one variable to another, the reference is copied, not the object's data. At that point, both variables hold a valid reference to the the object and the actual object data cannot be garbage-collected until both variables are cleared (set to NULL or another object reference). This is one reason why "dangling references" are such a problem in Java as well as C++. Caveat programmer!

2

We are all guilty of speaking a kind of shorthand about objects and variables. Most of the time it's OK, but when we talk of call by value etc it really matters.
An object is an object. A variable is not an object and an object is not a variable.
What we call an object variable is correctly a reference variable. It holds a reference to an object (or null).
So "all Java objects are references" is well-intended, but strictly false. It's the variable that's a reference, not the object.

Edited by JamesCherrill

Votes + Comments
Talk objectively to me. +1
Good explanation
0

JamesCherrill
Thanks ! Could uou please help me with the example via programm .It will be more clear for me.

Thanks in advance.

0

JamesCherrill
Hi James ,I want to become a good programmer as I am beginner .I just want to start in right way how to start by giving my giving effort .I want your help .
Could you provide me the direction .
Please could you help me.I will be very thankful to u for this.

0

I want a clear picture How internally the Hash Map works in Java?

1

I just want to start in right way how to start by giving my giving effort

Excellent. Glad you want to show efffort and start off on the right foot. However, your posts are coming off as a bit demanding and vague. Not saying that was your INTENT. Just saying that's how it came across, at least to me. Putting in effort requires that you spend time crafting your post to make it as clear as possible and in a way that we can quickly figure out what you want.

How internally the Hash Map works in Java?

This isn't the way to get help and this isn't a beginner question. How ANYTHING works internally isn't a beginner question.

Java is Strictly Pass by Value!

Ditto this "question" in the initial post. If it's a question, there should be a question mark somewhere. If it's not a question and it's intended to teach other people something, all the non-newbies already know this and no newbie can learn anything from this because you don't expand on the concept. So what is the point?

Step back, figure out what you want to accomplish with these posts, and start a new thread with a question that people can actually understand and answer please.

An example of a way you might rephrase your initial post might be something like the following...

Hi. I am a beginner in Java and I am trying to understand why I cannot pass by reference in Java like I can in C++. Googling "pass by reference in Java", I came up with this article...

http://javadude.com/articles/passbyvalue.htm

You could then continue by briefly explaining where you didn't understand something in the link and asking for clarification on it.

What this does is...

  1. Show you've put in some effort and googled the sources out there as opposed to simply posting here with no effort.
  2. Gives us a good idea of what your level is and exactly where you are stuck.
  3. Prevents us from simply replying with that link and telling you to read it because you already HAVE read it.

Ditto something like the Hash Map question. I'm not inclined to write several paragraphs on the subject for someone who may not have done any research on his/her own.

Have a look at this link. Should be required reading for forums. You'll get better responses if you follow the advice in it.

http://www.catb.org/~esr/faqs/smart-questions.html

0

Thanks for the suggestion.I will keep in my mind hereafter for asking any queries.

1

You'll do ok Kasis if you remember that you can find most of your answers on the Internet. Post here when you are totally bumfuzzled (confused). We will be happy to help then.

FWIW, a map is a collection of key/value pairs that is indexed on the key. A hash-map is a map where the keys are hash values of something, possibly the value, but not necessarily. In any case a map consists of unique keys - duplicate keys are not allowed, although duplicate values are allowed if necessary.

1

This thread is tagged Java, so let's assume that is the context.
HashMap in Java is a class in the standard API and it's definitive documentation is here
It's one implementation of the Java API's Map interface - documented here
The definitive Java Tutorials also explain Maps in more detail, and include a section on how to create a multimap. (I don't know why C+ multiimaps should be problematical. In Java they are very common and straightforward.)
Finally - don't ask about the internal implementation of Java Maps - only the public interface is defined so the implementation can, and does, change without notice between Java versions.

Edited by JamesCherrill

Votes + Comments
Seems the internet can't find the C++ definition of multi-map now... :-(
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.