Computers and Technology
Computers and Technology, 06.05.2020 07:12, Damani14

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)

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:50, laurentsofia09
Assume that you have an sorted array of records. assume that the length of the array (n) is known. give two different methods to search for a specific value in this array. you can use english or pseudo-code for your algorithm. what is the time complexity for each algorithm and why?
Answers: 1
image
Computers and Technology, 24.06.2019 08:00, qveenvslayin
How can smart devices benefit businesses, organizations, and social communities in the global marketplace?
Answers: 1
image
Computers and Technology, 24.06.2019 17:00, harlon852
The length of time that a slide appears before automatically advancing to the next slide can be set in the timing group under the transitions tab. transition to this slide group under the transitions tab. timing group in the master slide view. transition to this slide group in the master slide view.
Answers: 1
image
Computers and Technology, 24.06.2019 17:30, NEONREDBLADE
Match the following. 1. formatting that is applied when cell data meets certain criteria 2. borders with formats not found on the border tool 3. a shortcut bar that contains tools for commonly used formats 4. formats that can be applied to numbers conditional formatting custom borders format bar number formats
Answers: 3
Do you know the correct answer?
Can someone tell me what's wrong here? I'm starting at the index of 0, but getting this error.

Questions in other subjects:

Konu
Mathematics, 16.11.2019 02:31