i was doing this code to practice inheritance. i have declared a class "Laptop" and tried to call it in my main code, the thing is that the main code cannot seem to read it even though the spelling was right. Class Laptop Code Main Class Code
i tried importing the class Laptop unto my Main but it didn't work
here is the code of the class "Laptop"
package com.mycompany.laptop;
/**
*
*
*/
public class Laptop {
String brand, color;
double size;
void type() {
System.out.println("Brand: " + brand);
System.out.println("Color: " + color);
System.out.println("Size: " + size );
}
void print(){
System.out.println("My Laptop");
}
}
Here is the code for the "Main" that tries to call the "Laptop" class
package com.mycompany.main;
/**
*
*
*/
public class Main {
public static void main(String[] args) {
Laptop a = new Laptop();
System.out.println("-Inheritance-");
a.brand = "HP";
a.color = "Black";
a.size = 15.7;
a.print();
a.type();
System.out.println();
}
}
the error was in the main that tries to call the Laptop class which is Laptop a = new Laptop();
when i hover the Laptop name it says this error,
"cannot find symbol
symbol: class Laptop
location: class Main"
edit: i have tried to import using the suggested comments below but the ide says that the package does not exist, here is the code
package com.mycompany.main;
/**
*
*
*/
import com.mycompany.laptop.Laptop;
import com.mycompany.laptop.*;
public class Main {
public static void main(String[] args) {
Laptop a = new Laptop();
com.mycompany.laptop.Laptop a = new com.mycompany.laptop.Laptop();
System.out.println("-Inheritance-");
a.brand = "HP";
a.color = "Black";
a.size = 15.7;
a.print();
a.type();
System.out.println();
}
}