-1

Package 1:

package Mypackage;

public class MyFirst {
    int a;
    MyFirst()
    {
      a=10; 
    }
}

Package 2:

package mySecondPackage;
import Mypackage.MyFirst;
public class MySecond extends MyFirst{

    public static void main(String[] args) {

    }
}

I got one error that is The import Mypackage cannot be resolved.

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

0

Then in the classpath of second project, add first project..
It must resolve your problem :)
Steps to fix it,
Open project properties(ALT+Enter) -> left side check for java build path --> Project tab right side and then add first project..

Mr.Chowdary
  • 3,389
  • 9
  • 42
  • 66
-2

your superclass constructor is not visible that's why it is giving error..try this...

  package pack1;

 public class MyFirst {
  int a;
  public MyFirst()
{
  a=10; 
 }

}


package pack2;
import pack1.MyFirst;
public class MySecond extends MyFirst{


public static void main(String[] args) {
  MySecond s= new MySecond();

 }

 }
learner
  • 365
  • 1
  • 3
  • 16