1 class called "Person"
name, last name and age of every person, with their getters and setters.
1 class called "Codes"
int code, String rank. Here I will put the codes for every person.
1 main class called "Simulator"
Instanciate new persons and show system.out.print messages.

What I need is to instanciate "Codes" inside of "Person" (Like that: private Codes code and use it in the Simulator. For example:

Don't really know how to use classes inside another classes that aren't the main class.

Please help !!

02-06-2012, 02:04 PM

Norm

Re: Use classes inside of other classes

Quote:

how to use classes inside another classes that aren't the main class.

It shouldn't make any difference where you use a class. It should work the same way.
Your coding syntax is not correct java so its hard to understand what you are trying to do.
Can you create a correctly written program that shows what you are trying to do.

What is this statement trying to do:

p1.Codes.code

It looks like you are trying to access the member codes in the Person class and then access the member code in that the Codes class.

It is hard to discuss your problem because of the confusion between class names and member names.
Your variable and class names do not follow naming conventions: classes begin with Uppercase, members with lower case.