小编Ale*_*lea的帖子

ArrayIndexOutOfBounds员工数据库程序的异常

我是java的新手,并且一直试图用它来衡量它.我一直在努力写一个概念验证员工数据库.一切正常,直到我输入最后一个员工条件,然后我得到一个ArrayIndexOutOfBoundsException.这是我的两个文件的代码.任何帮助,将不胜感激.

import java.util.Scanner;
public class EmployeeInterface 
{
    public static void main(String[] args)
    {
        Scanner Input = new Scanner(System.in);

        System.out.println("Please enter the number of employees to register.");
        int employeeCount = Input.nextInt();
        Employee.setEmployeeNumber(employeeCount);
        String employeeFullName;
        String employeeAddress;
        String employeeDateOfHire;

        for(int x = 0; x <= employeeCount; x++)
        {
            System.out.println("Please enter the full name of employee number " + (x + 1));
            Input.nextLine();
            employeeFullName = Input.nextLine();
            System.out.println("Please enter the address of employee number " + (x + 1));
            employeeAddress = Input.nextLine();
            System.out.println("Please enter …
Run Code Online (Sandbox Code Playgroud)

java database indexoutofboundsexception

1
推荐指数
1
解决办法
143
查看次数

类构造函数中的stackoverflow错误

请原谅可能是一个非常基本的问题,但我正在编写一个程序来存储员工信息,它可以正常工作,直到它尝试在我的员工类中设置信息.它给出了stackoverflow错误,我无法弄清楚为什么.谢谢你的帮助.

主要课程:

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner Input = new Scanner(System.in);

        System.out.println("Enter the number of employees to enter.");
        int employeeCount = Input.nextInt();
        Input.nextLine();

        Employee employee[] = new Employee[employeeCount];
        String namesTemp;
        String streetTemp;
        String cityTemp;
        String stateTemp;
        String zipCodeTemp;
        String address;
        String dateOfHireTemp;

        for(int x = 0; x < employeeCount; x++)
        {
            System.out.println("Please enter the name of Employee " + (x + 1));
            namesTemp = Input.nextLine();
            System.out.println("Please enter the street for Employee " …
Run Code Online (Sandbox Code Playgroud)

java stack-overflow constructor

0
推荐指数
1
解决办法
1623
查看次数