aspose file tools*
The moose likes Android and the fly likes How execution starts ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "How execution starts ?" Watch "How execution starts ?" New topic
Author

How execution starts ?

Nikhil Sagar
Ranch Hand

Joined: Apr 21, 2012
Posts: 216

execution starts from calling to onCreate method just like calling to main method in java
but main method is static and onCreate method method is non-static so there should be a object of Test class in this case to call this method ?
So my problem is where is that object ?



OCPJP 6 86%
Nikhil Sagar
Ranch Hand

Joined: Apr 21, 2012
Posts: 216

I was expecting Atleast one Reply.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42918
    
  68
Maybe because the answer seems obvious: Android creates that object.
Nikhil Sagar
Ranch Hand

Joined: Apr 21, 2012
Posts: 216

Ulf Dittmer wrote:Maybe because the answer seems obvious: Android creates that object.


if it is that much obvious and having no problems then why not java Designers release a new version with the same concept where jvm can create object before calling to the main method.
and if it is that much obvious than why create a object (and waste memory although in case of mobile device memory is limited too) if you have a concept to make onCreate method static .
and I think you meant DVM in place of Android ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42918
    
  68
Differentiating between Android and the DVM seems like splitting hairs - Android is nothing without the DVM.

But you're mixing Java and Android, which are two different kinds of VMs. The JVM is established - why would anyone go to the trouble of releasing a new version that did allocate an object of the class that contains the main method if ALL desktop Java apps out there assume that that is not happening? Lots of apps might break if that were to happen. In fact, many Java desktop apps allocate an instance of that class in the main method.

Furthermore, allocating that object on Android is not a waste of memory, as the object is used by the application.
Nikhil Sagar
Ranch Hand

Joined: Apr 21, 2012
Posts: 216

Sorr for the late reply.
But , thanks marshal...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How execution starts ?