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



C++ const in java is final!!!


<josh.s17@xxxxxxxxx> wrote in message
news:1141127163.990162.225510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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++.



.



Relevant Pages

  • Re: final parameters
    ... make sure that, if applicable, all the parameters were declared const. ... This difference is primarily from the fact that java passes everything ... actually recall reading something to that effect (declaring everything ... public void test(final int val1, ...
    (comp.lang.java.programmer)
  • Re: final parameters
    ... make sure that, if applicable, all the parameters were declared const. ... Is there a backlash in Java doing so? ... FinalTest ft = new FinalTest ... public static void finalParam{ ...
    (comp.lang.java.programmer)
  • Re: java final vs. c++ const
    ... > to achieve the first form in java? ... Don't know much about C++, but from your example, it seems like "const ... final public int i; ... public A(int initialValueForI) { ...
    (comp.lang.java.programmer)
  • Re: How do java programmers cope with java missing c++ const?
    ... I do not miss const. ... In Java, to make classes thread-safe and to manage the complexity of ... immutability sort-of-means that every time an ... If an object is not immutable it is always being passed as non-const. ...
    (comp.lang.java.programmer)
  • Re: coding trick to reduce number of small objects generated
    ... I often long for const in Java, ... >especially when I have to do this type of cloning to prevent users from ... Complicit Bush-friendly media keeps mum. ...
    (comp.lang.java.programmer)