-1
I am learning POO by Java and this would be my first code, outside the classic hello world kkk.
How long to compile it via bash, the following error appears:
class2.java:12: error: class, interface, or Enum expected
package aula2;
^ 1 error
From my minimum experience, the error would be in line 12 of the code, with the name "package aula2;", but I cannot understand which error happens in this line...
Follows the code:
package aula2;
public class Aula2 {
public static void main(String[] args)
{
Caneta c1 = new Caneta();
c1.color = "Blue";
c1.model = "Bic";
}
}
package aula2;
public class Caneta
{
String model;
String color;
void status()
{
System.out.print("Uma caneta " + this.color);
System.out.print("A marca da caneta é " + this.model);
}
}
Could give me a light to understand kk?
Thanks!
But these are separate files? Declaring the package name twice in the same file is an even error, moreover, you cannot declare two public classes in the same file, as each file can only export one class.
– Andre
I was in doubt to answer you, but I think it’s the same file... as the classes, I didn’t know. The video I saw showed like this. How would you like to move?
– hiyan