I start with OOP And i have following problem: I made a new class Then I made ainstance from this class Now, for every instance I want to do something I tried it with a for each loop but it doesn't work... There are some syntax problems
This is the class:
package main;
public class command
{
String call;
String execute;
}
And this from the Main class:
private static void load() {
command greeting = new command();
greeting.call = "hello";
greeting.execute = "Hello Sir";
for (command c: command) {
System.out.println("Another command...");
}
}
I don't know how to make the loop or is there another way to do it?

for each, you need some kind of collection. Create, for instance, aListof commands, add 1 or more elements to this list and loop over that list.Iterablecontainer, e. g.List