There’s no equivalent to the C const “type modifier” in Java (sadly).
The closest you can get is to return an immutable object or an immutable wrapper around a mutable object.
Immutability is not a language feature of Java, however, so you’ll have to rely on Libraries.
Examples of immutable objects are:
- the primitive wrappers
Integer,Character, .. StringFileURL
Commonly used immutable wrapper (i.e. wrappers around mutable types that prevent mutation) are those returned by the Collecton.unmodifiable*() methods.