Google Galaxy Nexus — Some method without reference variable

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Aug 16, 2017 7:41:56 PM via Website

Hi everyOne i am confused in one concept .

I know that when we extend class we can use all the methods of the superclass or parent class ..

But suppose we do not extend class and we want to use the mehod of the superclass which is now not extended

I can just create the object of class in the class in which i want to use its methods

Class myClass = new Class ();
myClass.someMethod() ;
 
Question :

But when i extends the class Still do i need to create the object of class to use its method ?

Example ..
When in android we use findViewById method to fetch the view

Cuz its a method so there should be reference variable to that object that refer the method i.e AppCompatActivity ?

This is what i mean

First extenda appCompatActivity class
Then create its object
Like

AppCompatClass acc = new AppCompatClass ();
then use acc.findViewById() ;

But in Android atudios we direct use the method

View v = findViewById ();

— modified on Aug 16, 2017 7:52:12 PM