Marvin D
Marvin D

Reputation: 89

What's the difference between these two approaches to class initialization?

I'm new to Android. Can someone explain the difference between these two approaches to class initialization?

jamba = new JambaApplication(); 
jamba = (JambaApplication)  getApplication();

Upvotes: 0

Views: 96

Answers (1)

Mgamerz
Mgamerz

Reputation: 2890

One creates a new instance of Jamba Application and assigns it to Jamba (= new JambaApplication()),

And one gets the current application (or whatever getApplication() returns) and casts it to a JambaApplication (which may throw casting errors), and assigns it to Jamba.

You should study some java though since this is basic java.

Upvotes: 3

Related Questions