How to you make sure that a variable passed to a method isn't altered by the method? I know in C++ you can do something like
void aMethod(const Object &item)
{
........
}
I know that you can stop a variable from being reinitialized in java by doing this
void aMethod(final Object item)
{
.........
}
However, that won't stop it from calling a setter on the item or changing something in it.
Is there some other keyword out there that can do this?
Heck, I just found that java DOES recognize the const keyword but that it really is useless.
I heard that you can possibly use an Accessor class to deal with that but that would be so grueling that it wouldn't be worth it as it would have to be for every class!!!!
So, do you know of any practical way that const can be further approximated in java beyond using final?