subject

Can someone tell me what's wrong here? I'm starting at the index of 0, but getting this error.
import java. util.*;
import java. io.*;

public class Person{

private String person;
private String mother;
private String father;
private String [] array;

public Person (String person, String mother, String father, String [] array){

this. person = person;
this. mother = mother;
this. father = father;
this. array = array;

if (mother. equals("n/a")){

mother = "not found";

}

if (father. equals("n/a")){

father = "not found";

}

}

public String getPerson (){

return this. person;

}

public String getMother (){

return this. mother;

}

public String getFather (){

return this. father;

}

public String [] getKids (){

String [] kids = {"","","","",""};

for (int i = 0; i < array. length - 1; i++){

String name = array[i];
kids[i] = name;

}

return array;

}

}

My error:

Exception in thread "main" java. lang.: Index 3 out of bounds for length 3
at Person. getKids(Person. java:62)
at FamilyTree. getKidsLine(FamilyTree. java:129)
at FamilyTree. printFamilyTree(FamilyTree. java:73)
at FamilyTreeClient. main(FamilyTreeClient. java:10)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:00
Which of the following has not been attributed at least in part to social media a. drug addiction b. depression c. kidnapping d. murder
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Selling a product through an electronic medium is
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
Write a program in plp assembly that counts up by one starting from zero (or one) inside a loop and writes this value to the leds every time the value is increased. the memory address of the leds is 0xf0200000. the table below shows the meaning and an example usage of the instructions covered in the video, plp instructions for project 1. instruction example usage meaning load immediate li $t0, 8 register $t0 is set to the value, 8. store word sw $t2, 0($t1) the value in register $t1 is used as the memory address. the value in register $t2 is copied into this memory address. add addiu $t4, $t3, 29 register $t4 is assigned the sum of 29 and the value in register $t3. jump j your_label_name the program jumps to the line following the label, "your_label_name: ". label your label name: defines a label called "your_label_name: " that can be jumped to
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
File account.java (see previous exercise) contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and return a string representation. note that the constructor for this class creates a random account number. save this class to your directory and study it to see how it works. then write the following additional code: 1. suppose the bank wants to keep track of how many accounts exist. a. declare a private static integer variable numaccounts to hold this value. like all instance and static variables, it will be initialized (to 0, since it’s an int) automatically. b. add code to the constructor to increment this variable every time an account is created. c. add a static method getnumaccounts that returns the total number of accounts. think about why this method should be static - its information is not related to any particular account. d. file testaccounts1.java contains a simple program that creates the specified number of bank accounts then uses the getnumaccounts method to find how many accounts were created. save it to your directory, then use it to test your modified account class.
Answers: 3
You know the right answer?
Can someone tell me what's wrong here? I'm starting at the index of 0, but getting this error.
Questions
question
Mathematics, 22.04.2021 02:40
question
Mathematics, 22.04.2021 02:40
question
Mathematics, 22.04.2021 02:40
Questions on the website: 13722363