-
How the object of main class is created?
Hi All,
I have recently started JAVA prgramming.I am confused with the way java
handles the creation of object of main class of the program.I mean how and
when the object of the main class(Which is the name of the .java file itself)
is created.
for example,consider the simple program structure
class temp
{
public static void main(String args[])
{
//some code
}
}
Now,how and when the JAVA creates the object of class temp.
Looking forward for reply.
Thank you.
-Vikas.
-
Re: How the object of main class is created?
A temp object is never created. Since you're calling a static method on
temp, you'll never get a temp object.
HTH,
Jason
"Patel V D" <patel_vikasp@hotmail.com> wrote in message
news:38f3677b$1@news.devx.com...
>
> Hi All,
> I have recently started JAVA prgramming.I am confused with the way java
> handles the creation of object of main class of the program.I mean how and
> when the object of the main class(Which is the name of the .java file
itself)
> is created.
> for example,consider the simple program structure
> class temp
> {
> public static void main(String args[])
> {
> file://some code
> }
> }
> Now,how and when the JAVA creates the object of class temp.
>
> Looking forward for reply.
> Thank you.
> -Vikas.
-
Re: How the object of main class is created?
Hello Patel:
The main() method is called automatically by the JVM. If you choose to create
an object of type temp, you need to instantiate it like any other object
- call its constructor (this means you'll need to add a constructor to your
class).
Tom Duffy
"Patel V D" <patel_vikasp@hotmail.com> wrote:
>
>Hi All,
> I have recently started JAVA prgramming.I am confused with the way java
>handles the creation of object of main class of the program.I mean how and
>when the object of the main class(Which is the name of the .java file itself)
>is created.
> for example,consider the simple program structure
> class temp
> {
> public static void main(String args[])
> {
> //some code
> }
> }
> Now,how and when the JAVA creates the object of class temp.
>
>Looking forward for reply.
>Thank you.
> -Vikas.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks