Create objects dynamically. Back to basics
<p>I am writing a simple program to list the name of the companies and the workforce in JAVA.</p>

<p>I would like to create objects dynamically. Below is the code</p>

<pre><code>public class EmployeeRecord {

/**
 * @param args
 */
String company, name;
int employee;
public String input;
public static BufferedReader br;
public int iE;
public static String numberOfCompanies;
String nameOfCompany;*/

public void company(String input) {
    // TODO Auto-generated method stub

    nameOfCompany = input;
}

public void employee(String employeeNumber) {
    // TODO Auto-generated method stub
    iE = Integer.parseInt(employeeNumber);
}*/

public static void main(String[] args) {
    // TODO Auto-generated method stub

    EmployeeRecord qw = new EmployeeRecord ();
    try {
        br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter number of companies: ");
        numberOfCompanies = br.readLine();
        int G = Integer.parseInt(numberOfCompanies);

        for (int i = 1; i &lt;= G; i++) {

            System.out.println("Enter name of the company: ");
            String company = br.readLine();
            qw.company(company);
            System.out.println("Enter Number of employees: ");
            String employeeNumber = br.readLine();
            qw.employee(employeeNumber);

        }

        for (int i = 1; i &lt;= G; i++) {

            qw.sortCompanySummary();
        }
    } catch (IOException io) {
        io.printStackTrace();
    }

}

public void companySummary() {

    System.out.println("Number of companies: " + numberOfCompanies);
    System.out.println("Name of company: "+nameOfCompany);
    System.out.println("Number of employees: "+iE);


}

}
</code></pre>

<p>What I would like to do over here is create separate instances of the class EmployeeRecord dynamically. eg </p>

<pre><code>EmployeeRecord qw = new EmployeeRecord();
EmployeeRecord we = new EmployeeRecord();
</code></pre>
