0
I have 2 codes:
Code 1:
class Principal {
public static void main(String[] args){
Pessoas pessoa1 = new Pessoas();
pessoa1.idade = 1;
pessoa1.nascimento = 2;
pessoa1.altura = 0.5;
pessoa1.nome = "texto";
}
}
Code 2:
class Pessoas {
int idade;
int nascimento;
double altura;
String nome;
public static void main(String[] args){
}
}
I’ve tried using the package
and import
, but it didn’t work. I think I used them wrong. How do I use them to use code 2 in code 1?
NOTE: The two codes are in the same folder.
Yes, the 2 codes are in the same folder and I need the code 1 to access the code 2 to create the personal data1
– Shintaro
Worked normally with me.
– user28595
error here saying that
Pessoas pessoa1 = new Pessoas();
says it is not possible to find the symbol People– Shintaro
So you’re not putting them both in the same package.
– user28595
the 2 are in the same folder and the code is exactly as I put in the post
– Shintaro
As I said, I simulated here and gave nothing, this error occurs when a class is not oncocentered. If you were both in the same package, you wouldn’t make this mistake.
– user28595
how do I put the 2 in the same package? to see if this error goes missing
– Shintaro
If you are using eclipse or netbeans, just drag the class to the same package as the other one is.
– user28595
I don’t use any of the 2 create the code using Notpad++, I can’t use any of the 2
– Shintaro
No ide, just put the files in the same folder.
– user28595
then I’m using in the same folder put in the cmd says that
Pessoas pessoa1 = new Pessoas();
it is not possible to find the sinbulo People– Shintaro
Well, then I don’t know how to help you. Because I simulated creating in the ide, then manually creating in the Notepad and cmd, and in both ways it worked normally here. The problem is in another procedure you are doing.
– user28595
What command are you using to compile these files?
– Victor Stafusa
javac "filename". java
– Shintaro
@Clockwork You are compiling which file first?
– Jéf Bueno
Enter the entire code, including the Imports.
– Pablo Almeida
@Pabloalmeida however incredible it may seem, the code is just that, there are no Mports. If you save both, normal wheel, I believe this question is a XY problem.
– user28595
@Clockwork Put the exact command you are using to compile. If you have more than 1 class to compile you have to compile all of them, for example
javac *.java
– Isac