避免在我的类中使用extends和implements。

huangapple go评论75阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年8月11日 16:12:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/63354115.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定