File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes using final while creating object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using final while creating object" Watch "using final while creating object" New topic

using final while creating object

shruti patel
Ranch Hand

Joined: Mar 10, 2008
Posts: 52
Is it a legal statement.

Final Demo d=new Demo();

sharad sinha

Joined: Jul 13, 2008
Posts: 26
Yes it is correct. References can be final. Final references can not be reassigned to anything else once an object is assigned. The state of the object however can change. There is nothing called final object in Java. Also it should be final not Final.
[ August 23, 2008: Message edited by: sharad sinha ]

Thanks, Sharad<br />SCJP 5 (July, 2008)
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15081

Originally posted by shruti patel:
Is it a legal statement.

Final Demo d=new Demo();

No, because Java is case-sensitive and "Final" is not a Java keyword.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: using final while creating object
It's not a secret anymore!