kutayatesoglu kutayatesoglu - 6 months ago 9
Java Question

How to update a class properly in Eclipse

When I update or add a constructor in a class, Eclipse doesnt update the class in other scrapbook which I imported the class before.

For example my class code is like this;

public class Car{
public Car(){
super();
}
}


In an scrapbook I import this class an create a Car instance. But when I try to update my original class to this and try to create another Car instance;

public class Car(){
public Car(String brand, String year){
super();
this.brand= brand;
this.year= year;
}
}


It gives me the error "The constructor Car(String, String) is undefined".

The error goes away after I close and re-open Eclipse one time. Can someone help me how to update a class properly.

Answer

In most cases the main cause is that you didn't save the Car.java file. Remember to press Ctrl+S every time you edited a file.