java rutime error on test 1

Revision en1, by soumiaMoufid, 2017-02-05 01:44:18

please i got "rutime error on test 1" with this code any help?? thanks in advance

package graph.party;

import java.util.ArrayList;
import java.util.Scanner;

public class Party2 {

	public Party2() {
		Scanner in = new Scanner(System.in);
		System.out.println("entrez le nombre des employés\n");
		int n = in.nextInt();
		ArrayList<Integer> tab=new ArrayList<Integer>(n);
		for(int i=0;i<n;i++){
			tab.add(in.nextInt());
		}
		int result=0;
		for(int j=0;j<n;j++){
			int temp=1;int var=tab.get(j);
			while(var != -1){var=tab.get(var-1);temp++;}
			if(temp>result) result=temp;
		}
		System.out.println(result);
	}

	public static void main(String[] args) {
		new Party2();

	}

}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English soumiaMoufid 2017-02-05 01:44:18 762 Initial revision (published)