I write some coding i want to get 2 output like
Example (1) of object Employee:
 Id#
 Name :
 Age:
 Sex:
 etc.
Example (2) of object Employee:
 Id#
 Name :
 Age:
 Sex:
 etc.

i just dont want a long code..

import java.io.*;
import java.util.Scanner;
public class Main {

     * @param args the command line arguments
    public static void main(String[] args) {
        int i =0;
        int[] iDNumber = new int[5];
        String name;
        int age;
        String sex;

        Scanner scan = new Scanner(System.in);
        Employee employ = new Employee();
        String two;
        System.out.print("Please enter an ID number: ");
        iDNumber[1] = scan.nextInt();

        System.out.print("Please enter the employees name: ");
        name = scan.nextLine();
        name = scan.nextLine();

        System.out.print("Please enter the employees age: ");
        age = scan.nextInt();

        System.out.print("Please enter employees sex: ");
        sex = scan.next();

        System.out.print("Please enter the employees Salary ");
        double salary = scan.nextDouble();

        System.out.print("Please enter the employees jobtitle ");
        String jobTitle = scan.nextLine();
        jobTitle = scan.nextLine();
        String ONE = employ.employee1();
        two = employ.employee1();
        System.out.println(ONE + "\n" + two);


Make two employ objects. Wrap your user-input section in a loop and load each object with the correct data. Then, outside of the loop, you can simply output each object. I don't know what's in your employ class, but you could add a method to output the data, or you could just add accessors to output the data in your main method.

This article has been dead for over six months. Start a new discussion instead.