I want to first point out that I am very new to Java so go easy. :)

I have a method that randomly generates a name.
I'm just wondering if it is better practice to call methods with return types directly like this:

```
String personName = People.nameGen();

```

or as I've recently learned, create 'get' methods to get the 'instance?' variables like this:

```
public String getName(){
return this.name;
}

```

then:

```
String personName = Person1.getName();

```

I've tried both and they seem to work identical, I can't seem to wrap my head around why you would use one way other another.

or even call the instance variables directly..?

```
name = People.name; or something like that?

```

All of these options would generate the output of a name of the person that I generated in that method.

EDIT, This is what I have:

```
import java.util.Random;
public class People {

int genderCode;
int age;
String gender;
String name;

public People(){
    genderCode = genderCode(); //I use genderCode for the nameGen method
}

public int genderCode(){
    Random randNum = new Random();      
    genderCode = randNum.nextInt(2);
    return genderCode;
}

public int age(){
    Random randNum = new Random();      
     age = 1+randNum.nextInt(80);
    return age;
}   

public String gender(){
    if (genderCode == 0 && age <=18) {
        gender = "girl";
    } else if (genderCode == 0 && age >18){
        gender = "woman";
    } else if (genderCode == 1 && age <=18){
        gender = "boy";
    } else if (genderCode == 1 && age >18){
        gender = "man";
    } 
    return gender;
}

public String nameGen() {
    String[] firstNameGirl = { "Lucy", "Marry", "Bonnie", "Clair" }; //More names will be added later
    String[] firstNameBoy = { "Bob", "Jacob", "William", "Nathan" };
    String[] lastName = { "Smith", "Brown", "Johnson" };

    Random randNum = new Random();

    if (genderCode == 0) {
        String girlName = firstNameGirl[randNum.nextInt(firstNameGirl.length)]+ " "+ lastName[randNum.nextInt(lastName.length)];
        name = girlName;
    } else if (genderCode == 1){
        String boyName = firstNameBoy[randNum.nextInt(firstNameBoy.length)]
                + " " + lastName[randNum.nextInt(lastName.length)];
        name = boyName;
    }
    return name;
}
}

```

Then for the main, I just want to make a new person at will.. eg:

```
System.out.println("You meet a " +age+ " year old " +gender+ " named " + name);

```

Thanks to all the quick answers! They were all uniquely informative!