英文:
Avoid using extends and implements in my class
问题
I am brand new to Java and need to use one of the following class definitions in my project.
import androidx.fragment.app.Fragment;
public class ScannerFragment extends Fragment implements myclass {
... ... ...
}
Or:
public class MainActivity extends AppCompatActivity implements myclass {
... ... ...
}
However, I cannot seem to understand how to implement the androidx.fragment.app.Fragment
as I dont have any gradle.properties file. I am using Pyjnius that allows me to use Java in my Python project.
So my question is: Is there a way to avoid using Fragment
or AppCompatActivity
in my code and implement the class myclass
in another way? I dont understand the extend
and implements
method.
英文:
I am brand new to Java and need to use one of the following class definitions in my project.
import androidx.fragment.app.Fragment;
public class ScannerFragment extends Fragment implements myclass {
... ... ...
}
Or:
public class MainActivity extends AppCompatActivity implements myclass {
... ... ...
}
However, I cannot seem to understand how to implement the androidx.fragment.app.Fragment
as I dont have any gradle.properties file. I am using Pyjnius that allows me to use Java in my Python project.
So my question is: Is there a way to avoid using Fragment
or AppCompatActivity
in my code and implement the class myclass
in another way? I dont understand the extend
and implements
method.
答案1
得分: 0
Extends 意味着你想从现有的类派生一个子类。Implements 意味着你将实现一个接口。
英文:
Extends means you want to derive a subclass from an existing class. Implements means you will implement an interface.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论