Re: How do java programmers cope with java missing c++ const?



josh.s17@xxxxxxxxx wrote:
I've been working with java for a while now, but I miss the ability to
pass around objects that can't be modified, as is possible with the c++
const keyword. Is it just me or do others find this a limitation of
java? I've read the way to do it in java is to pass around immutable
objects however that seems a lot less flexible than having the ability
to pass a const reference to a mutable object as can be done in c++.

I miss it a bit, but if it's necessary you can do something similar, not with an immutable object, but with an "immutable interface":

http://home.arcor.de/kkaehler/2005/04/no-const-in-java.html
.



Relevant Pages