-5
Fragment fr1 =new FragmentABC();
and 
Intent in = new Intent();

where Fragment and Intent are build class while FragmentABC is user defined class.

Its pretty basic but still cant figure out the reasonable difference to justify on instantiating. Want to know what's the difference between two statements, please be descriptive in the answers you provide.

  • This post might help you: http://stackoverflow.com/questions/18100417/whats-the-core-difference-between-fragment-and-activity-which-code-can-be-writ – joao2fast4u Apr 04 '14 at 10:32
  • The question redirected is not a relevant answer the question is regarding instantiating....!! – user3371013 Apr 04 '14 at 10:35

3 Answers3

0

you can initialize a class statements by any of the following

ClassName name = new ClassName();

or

SuperClassName name = new ClassName();

So according to the above example in the second case the Intent object is initialized. And in the first example it seems like the FragmentABC is a child class of Fragment

stinepike
  • 54,068
  • 14
  • 92
  • 112
0

Both statements create a new object and both hold them in local scope.

The only difference is: Fragment has to be a super-type of FragmentABC because otherwise the first statement may not be compiled.

matt
  • 153
  • 7
0

The main difference between the two statements in terms of Instantiating is that in first one, you are instantiating a FragmentABC object, that extends the Fragment class. This means your FragmentABC object is a subClass of Fragment. In the second one you are instantiating an Intent, that is a normal class being instantiated.

To know more about this, you can check this post.

Community
  • 1
  • 1
joao2fast4u
  • 6,868
  • 5
  • 28
  • 42