Question: I am new to Java game programming, but the more I read the more I'm confused, because I've seen several different approaches to make a game loop:
1. The standard approach, that uses the Timer class (seems to be less precise).
2. The more precise approach that uses System.nanoTime.
3. A simple approach that uses scheduleAtFixedRate.

Which one should generally be preferred and where are the advantages/disadvantages of each approach? Thanks in advance for any info.

Answer: 
It depends on how you're storing things internally.

Here's an example, though it's not terribly efficient, that uses your format:

```
public Vector<Trainer> loadData(BufferedReader in) throws IOException {
  Vector<Trainer> trainers = new Vector<Trainer>();

  String line = in.readLine();
  String[] split;
  while (line != null) {
    split = line.split(";");
    if (split[0].equals("@Trainer")) {
      int count = Integer.parseInt(split[1]);
      Trainer t = new Trainer();
      for (int i=0; i < count; i++) {
        t.add(Pokemon.createMonster(in.readLine().split(";")));
      }
      trainers.add(t);
    }
    line = in.readLine();
  }
  return trainers;
} // end loadData()

```

I'm also sidestepping the issue of the varying parameter counts for each type of pokemon by passing the split array on to the creation method.

Strictly speaking, you don't *really* need the "@Trainer" and "@Pokemon" bits, because the system will automatically differentiate between trainers and monsters. That's how helpful the monster-count information is.

If you'd rather, you could also store things in a database, like SQLite, and pack things into tables instead.

Here are some example tables:

```
CREATE TABLE Trainers (
  id INTEGER PRIMARY KEY,
  name TEXT NOT NULL
);
CREATE TABLE Monsters (
  id INTEGER PRIMARY KEY,
  type INTEGER NOT NULL,
  owner INTEGER FOREIGN KEY (Trainers.id),
  parameters TEXT NOT NULL
);

```

By using a `parameters` column, you're avoiding the need for individual columns for each parameter for each monster type. Formatting would be whatever you want, including the semicolon-separated method you mention.
If you want a format that's easy to edit, read and write, XML or JSON are great choices.

**They are not very efficient** - they use a LOT more space than the format you suggested - but they are supported by many tools, and having labels on the fields makes it easy to change the format later without any confusion about what each value means.

example file:

```
{ 
trainers: [
    { "level":5
      pokemons: [
        {"level":12,"attack1":1,"attack2":3,"attack3":4},
        {"level":13,"attack1":1,"attack2":2}
         ]
    }
    { "level":2
      pokemons: [
        {"level":2,"attack1":1,"attack2":2,"attack3":3},
        {"level":2,"attack1":1,"attack2":2,"attack3":3}
         ]
    }
    ]
}

```

Java

```
import java.util.List;

import com.google.gson.Gson;

public class JsonTest {

    public static void main(String[] args) {
        new JsonTest().start();
    }

    private void start() {
        Gson gson = new Gson();

        // Pretend this was read from a file
        String examplePokemonsString = "{ trainers: [{ level:3, pokemons: [{level:3,attack1:1,attack2:2,attack3:3},{level:3,attack1:1,attack2:2,attack3:3}]}]}";

        DataFile data = gson.fromJson(examplePokemonsString, DataFile.class);

        List<Trainer> trainers = data.trainers;
        Trainer firstTrainer = trainers.get(0);
        Pokemon firstPokemon = firstTrainer.pokemons.get(0);
        System.out.println(firstTrainer.pokemons.size()); //This trainer has 2 pokemon
        System.out.println(firstPokemon.level); // First pokemon is at level 3
    }

    class DataFile {

        List<Trainer> trainers;
    }

    class Pokemon {
        int level;
        int attack1;
        int attack2;
        int attack3;
    }

    class Trainer {
        int level;
        List<Pokemon> pokemons;
    }
}

```