Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
Author

using final while creating object

shruti patel
Ranch Hand

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

Final Demo d=new Demo();

Explain
sharad sinha
Greenhorn

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: 14114
    
  16

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 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using final while creating object