What is the Java equivalent of C++'s const member function?
<p>In C++, I can define an <em>accessor</em> member function that returns the value of (or reference to) a private data member, such that the caller cannot modify that private data member in any way.</p>

<p>Is there a way to do this in Java?</p>

<p>If so, how?</p>

<p>I know about the <code>final</code> keyword but AFAIK, when applied to a <em>method</em> it:</p>

<ol>
<li>Prevents overriding/polymorphing
that method in a subclass.</li>
<li><strike>Makes that method inline-able.</strike> (see comment by @Joachim Sauer below)</li>
</ol>

<p>But it doesn't restrict the method from returning a reference to a data member so that it can't modified by the caller.</p>

<p>Have I overlooked something obvious?</p>
