If I want to generate a Java instances of a simple object with random values.

For Example, For class :

```
class Entity {
    int id;
}

```

I want to add generate function that initialize an new instance with random value for id .

What is the best OOP method? I thought about 2 options:

1. To create static method in Entity class:

```
class Entity {
  int id;
  public static Entity generate(){
      Entity e = new Entity ();
      int rand = MathUtil.generateRandomInt(); // method in util class 
                 in the project.
      e.setId(rand )
      return e;
 }
}

```
2. To Create EntityGenerator class:

```
 class EntityGenerator{
     public Entity generate(){
      Entity e = new Entity ();
      int rand = MathUtil.generateRandomInt(); // method in util class 
                 in the project.
      e.setId(rand);
      return e;
    }

}

```

I hesitate what is the better option.