Re: [Hampshire] Happy Happy Joy Joy

Top Page

Reply to this message
Author: Graham
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] Happy Happy Joy Joy
On Sun, 2007-09-23 at 10:27 +0100, Samuel Penn wrote:
> On Sunday 23 September 2007 09:52:35 Graham wrote:
> [...snip stuff about Java and C++...]
> > The lack of an object lifecycle and the lack of constness are just two
> > of the things that continue to frustrate me with Java.
>
> What do you mean by these? I think I know about you mean, but
> don't see how they're lacking in Java. Unless you mean you don't
> like garbage collectors. The final keyword gives you constants.


There's no object lifecycle because there's no guarantee when a
destructor will be called, if ever. Unlike C++, the scope doesn't
define when an objects destructor is called. Hence destructors in java
are rarely defined. It would be useful if you could indicate when a
variable is declared if it is to be scoped and the destructor should be
called.

As for final, it is not the same as const. It only indicates that a
variable won't be reassigned, but you can still change its state.

For instance ...

class X{
private int m_i;
public X(final int i){ m_i = i }
public void setX(final int i){ m_i = i; }
public int getX(){ return m_i; }
}

Now this declaration:

final X myX = new X(123);

Final means I can't do this...

myX = new X(456);

But I can do this...

myX.setX(789);



Graham