I have rewrite my code and I ran into some problems.
I have two problems.
1. What does this mean "Type safety: The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized" at this statement
Expand|Select|Wrap|Line Numbers
- arlist.add(temp);
Expand|Select|Wrap|Line Numbers
- for(String idx : empid
Thanks
nomad
here is my code
Expand|Select|Wrap|Line Numbers
- import java.util.*;
- class Employee {
- static final int size = 10;
- private String empid;
- private String lname;
- public Employee(String id) {
- empid = id;
- }// close the employeeclass loop
- /**
- * Constructors.
- */
- public Employee() {
- }
- public Employee(String id, String fn) {
- empid = id;
- }// close public EmployeeClass
- /*
- * accessors make info available
- */
- public String getEmpId() {
- return empid;
- }
- /*
- * Mutator Methods
- */
- public void setEmpId(String id) {
- this.empid = id;
- }
- }
- /**
- * The EmployeeDatabase class stores each Employee in an arraylist. Methods
- * exist to add new Employees, search Employees, and print Employees to the
- * console.
- */
- public class Employee_listing {
- static ArrayList arlist;
- int empid = arlist.size();
- /**
- * displayMatch inputs a keyword from the user. It then iterates through the
- * ArrayList of Employees and outputs each one to the screen if the Employee
- * information contains the keyword.
- */
- public static Employee inputEmployee() {
- Employee temp = null;
- Scanner input_flag = new Scanner(System.in);
- System.out.println("Enter Employee Id Number AB1234==>");
- String empid = input_flag.next();
- //need to add find section here
- System.out.print("Enter Last Name Doe==>");
- String ln = input_flag.next();
- System.out.print("Enter First Name John==>");
- String fn = input_flag.next();
- System.out.print("Enter Street ==>");
- String st = input_flag.next();
- System.out.print("Enter City ==>");
- String ct = input_flag.next();
- System.out.print("Enter Zip ==>");
- String zp = input_flag.next();
- System.out.print("Enter years worked ==>");
- Integer years = input_flag.nextInt();
- System.out.print("Enter payrate as double ==>");
- Double pr = input_flag.nextDouble();
- // make an object
- temp = new Employee(empid, );
- return temp;
- }
- /**
- * @param Add
- * a employee to the db. using a scanner to see if an Employee is
- * in the db if no add them
- */
- public static void main(String[] args) {
- arlist = new ArrayList<Employee>();
- Scanner input_flag = new Scanner(System.in);
- int choice;
- System.out.println("Make a Section: ");
- System.out.println("1. Enter ");
- System.out.println("2. Find ");
- System.out.println("3. Exit ");
- System.out.print("\nPlease press Enter afer each response");
- System.out.println("Enter your chose please: ");
- choice = input_flag.nextInt();
- input_flag.nextLine();
- if (choice == 1) {// if 1 is select go to makePerson
- Employee temp=inputEmployee();
- arlist.add(temp);
- //--
- }
- /**
- * displayMatch inputs a keyword from the user. It then iterates through the
- * ArrayList of Employees and outputs each one to the screen if the Employee
- * information contains the keyword.
- */
- if (choice == 2) {// if 2 is select go to find
- String ans;
- System.out.print("Enter name==> ");
- ans = input_flag.next();
- // loop through the array
- int pos = 0;
- for(String idx : empid) {
- if( ans.equalsIgnoreCase(idx)) {
- break;
- } else {
- pos++;
- }
- }
- if(pos >= empid.length) {
- System.out.println("Did not find name");
- } else {
- //---
- }
- }
- if (choice == 3) {
- //--
- }
- }
- }