Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
233 views
in Technique[技术] by (71.8m points)

java - Error Message: Int cann't be converted to type

I am very very new to my intro to java course and I was looking for help with an error that I was receiving. The error message is posted below along with with the actual code. Does anyone know why I am receiving this message and anyway to help me? The code is able able to compile and run but instead of printing at the end I receive a pop up error message (screen shot below) but I don't understand what it means or why I am getting it. Can anyone help? Thanks!

   public class Employee10
{   
    public static void main ( String args[] )
    {
        Employee e1 = new Employee();
        Employee[] arr = new Employee[2];

        int j = 0;

        for ( int i=0; i < 3; i++)
        {
            arr[0] = e1;

            String nameF = Input.getString("Please enter a First Name");
            String nameL = Input.getString("Please enter a Last Name");
            int Number = Input.getInt("Please enter an Employee Number");
            String Street = Input.getString("Please enter a Street address");
            String City = Input.getString("Please enter a City");
            String State = Input.getString("Please enter a State");
            double Zip = Input.getDouble("Please enter a Zip Code"); 
            int Month = Input.getInt("Please enter a Month");
            int Day = Input.getInt("Please enter a Day");
            int Year = Input.getInt("Please enter a Year");

            e1.setNumber(Number);
            e1.setName( new Name(nameF, nameL));
            e1.setAddress(new Address(Street, City, State, Zip));
            e1.setHireDate(new Date(Month, Day, Year));

            System.out.println(e1.getEmployeeString());


            arr[i] = e1;

        }   

        for ( j=0; j < arr.length; j++ )
        {
            System.out.println( arr[j].getEmployeeString() );
        }   
    }
}

ERROR MESSAGE: ( Unfortunately I am not able to embed a photo so I just have to type out the code so here it is):

The Java class file "Employee10.class" could not be launched. Check the Console for possible error messages.

What does all of this mean? Where is the Console I can check?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try to do some thing like this:

  Employee e2 = new Employee(); 
  arr[j] = e2 ;

Because in arr you can add only elements of type Employee;


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...