So what I am trying to do is loop through an array filled with variables which are defined by my own class.
The class itself contains variables like integers and booleans, and I want to add other stuff later.
class Person {
int life = 100;
boolean alive = true;
}
and then I want to create an array which i’m going to fill with variables from my class.
static Person myArray[];
Now here i’m starting to get problems.
I’ve tried to fill the array with variables from my clsas through a loop but without success.
And I’m guessing that’s why I cant loop through my array like this:
for(int i=0; i<myArray.length; i++){
if(myArray[i].alive == true){
...
}
Grateful for help!