Here is a simple example for you.
Main.java
public class Main
{
public static void main(String[] args)
{
Person person = new Person("John Doe", 47);
System.out.println(person.name + ", " + person.age);
}
}
Person.java
public class Person
{
public String name;
public int age;
public Person(String _name, int _age)
{
name = _name;
age = _age;
}
}
In Java, every class has to go to its own file (with the same name as the class itself).
To use code from your classes, you'll need to reference them from your main().
In the example above, the Person class is instantiated via the constructor. In the next line, we print out the fields held by the Person class.
One program can have only one entry point (main() function). If you want a different program, create a new project.