Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Person {
- int num;
- }
- class Man {
- Person[] p; // creating an array of Person
- public Man(int size) {
- p = new Person[size]; // allocating memory the right size for the array
- for (int i = 0; i < size; i ++) {
- p[i] = new Person(); // making all the Person's in the array
- p[i].num = i;
- }
- }
- public static void main(String[] args) {
- Man man = new Man(5);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement