This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes re : System class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "re : System class" Watch "re : System class" New topic
Author

re : System class

ragi singh
Ranch Hand

Joined: Mar 10, 2010
Posts: 198

Hi ,

In the java docs its mentioned that the System class is defined as :- public final class System
and that it cannot be instantiated . I cannot understand why System class cannot be instantiated , as it is not static .
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4522
    
    5

You seem to be conflating different concepts here. A class being final doesn't have anything to do with whether or not an instance can be created.

Read the source of System.java which you will find in the src.zip archive in your jdk installation folder. Do you see a constructor? What access modifier is applied/ What do the comments say?


luck, db
There are no new questions, but there may be new answers.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13869
    
  10

ragi singh wrote:I cannot understand why System class cannot be instantiated , as it is not static .

Top-level classes cannot be static. And 'static' does not have anything to do with whether a class can be instantiated or not.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: re : System class
 
Similar Threads
If abstract classes can't be instantiated, what is System.in?
why System class instance cannot be instatiated
Private Constructor
classes with private constructors can not be subclassed?
abstract class