Hi, I'm kind of new to Java. I've been programming in C++ whenever possible. I'm starting to write some code in Java now and can't figure out how to create const functions.
In C++ you can declare a function with the const keyword after the function name, ex:
The const guarantees that the function will not modify the object's state (i.e. the member variables).
The closest equivalent I could find to const is the final keyword, but the description I read about final seems to indicate that it will only prevent derived classes from overriding that function...
Is there any equivalent in Java to making a function const?
In C++ you can declare a function with the const keyword after the function name, ex:
Code:
class SomeClass
{
public:
void SomeFunc() const;
};
The closest equivalent I could find to const is the final keyword, but the description I read about final seems to indicate that it will only prevent derived classes from overriding that function...
Is there any equivalent in Java to making a function const?