错误信息:无法将 Int 转换为类型 [英] Error Message: Int cann't be converted to type

查看:38
本文介绍了错误信息:无法将 Int 转换为类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Java 入门课程非常陌生,我正在寻求帮助以解决我收到的错误.错误消息与实际代码一起发布在下面.有谁知道为什么我会收到这条消息,无论如何要帮助我?该代码能够编译和运行,但不是在最后打印,而是收到一条弹出错误消息(下面的屏幕截图),但我不明白这意味着什么或为什么我会收到它.任何人都可以帮忙吗?谢谢!

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):

无法启动 Java 类文件Employee10.class".检查控制台以获取可能的错误消息.

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?

推荐答案

我完全理解你想要做什么,您正在尝试将下一个员工对象分配给当前的员工对象,而您编写的代码在语法上是错误的.

I completely understand what you are trying to do, You are trying to assign the next employee object to the current one, and the code you have written is syntactically wrong.

这里是需要修改的代码

arr[j] = ;

需要改成

arr[j] = arr[j+1];

这篇关于错误信息:无法将 Int 转换为类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆