Last active
December 19, 2021 10:18
-
-
Save sunmeat/f2ab3b180b790bfd5516 to your computer and use it in GitHub Desktop.
objects count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.alex.static; | |
class Location { | |
int totalCount; | |
class Monster { | |
int health; | |
int attack; | |
int mana; | |
Monster() { | |
totalCount++; | |
System.out.println("monster #" + totalCount); | |
} | |
} | |
Monster[] monsters; | |
} | |
public class Program { | |
public static void main(String[] args) { | |
Location location = new Location(); | |
location.monsters = new Location.Monster[2]; | |
location.monsters[0] = location.new Monster(); | |
location.monsters[1] = location.new Monster(); | |
} | |
} | |
// run: | |
// monster #1 | |
// monster #2 | |
// СБОРКА УСПЕШНО ЗАВЕРШЕНА (общее время: 1 секунда) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment