Unable to access classes in default package

I have a problem with the default package. Basically my project structure consists of three main classes that extend one abstract class in a package called imitation. Yesterday I made a name change in the project, and now my three main classes are automatically placed in the package by default, so they cannot be seen by the class inside the modeling package and vice versa. For the following code

import simulation.*;

class SSQSim extends Simulation{

} 

I get these errors "This class must implement the inherited abstract Simulation.stop () method, but cannot override it because it is not displayed from SSQSim. Either make an abstract type, or draw the inherited method" "No modeling visible"

Thanks in advance.

EDIT The problem is that I do not need to use other packages. This is mainly homework, and the rules for the presentation are quite strict: first, I have to present a package “simulation”, which contains an abstract class “Modeling” with some methods for implementation using other classes. This part is fine.

Then I need to create three classes that import batch modeling and extend its Modeling class. They specifically stated that they did not put these classes in any package. At first, everything worked fine, but after I renamed the project. These classes suddenly switched to the default package, and now they give me these errors.

+3
source share
4 answers

? , Eclipse New Java Class. , :

enter image description here

Browse, .

enter image description here no i do not like image descriptions >:(

+1

, java:

It is a compile time error to import a type from the unnamed package.

, , , .

+1

, Simulation.stop() , () simulation.

  • SSQSim simulation, , simulation,
  • simulation class-public.

eclipse, , eclipse .


(: , . , , , !)

0

, . , - . ( "" ) ( , ). , , , .

In short, if the child cannot “see” the method that is being reevaluated, the compiler issues a warning that informs of the inevitability to determine whether the method defined by the parent or child should be used at run time.

Regarding the Eclipse behavior of creating classes in a package by default, you can always make sure that the package is specified when creating a new class in the corresponding dialog box (a new Java Class dialog where the package field is present).

0
source

Source: https://habr.com/ru/post/1792020/


All Articles