-1

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.

Frederik Petri
  • 451
  • 8
  • 24
  • Do you know about the existance of `Types` and `Interfaces` in Python? If so, then in Java you can only `extend a class` single one per inheritor, and `implement an interface` multiple at a time.... – dbl Aug 11 '20 at 08:19
  • So the hint here is: 1) *If it is defined as `class` you can only extend by using `extends`* (should implement all abstract methods) 2) *If it is defined as `interface` then you can only `implemennts` it* (should implement all abstract methods).... – dbl Aug 11 '20 at 08:21
  • You don't have to implement Frame. This should answer your question: https://stackoverflow.com/questions/10839131/implements-vs-extends-when-to-use-whats-the-difference – roediGERhard Aug 11 '20 at 08:38

1 Answers1

0

Extends means you want to derive a subclass from an existing class. Implements means you will implement an interface.

Peter Nagy
  • 86
  • 1
  • 7