Bonjour, j'essaye de faire fonctionner un projet importé sans avoir de véritables connaissances du java. J'ai une erreur que j'ai retrouvée présentée plusieurs fois sur internet, apparemment liée à la taille d'un tableau. Néanmoins je ne vois quelle résolution appliquer.
La portion de code incriminée :
L'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 package fr.guehenneux.wordgen; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; import java.util.stream.Stream; /** * Based on sciencetonnante video * https://www.youtube.com/watch?v=YsR7r2378j0 * * @author Jonathan Guéhenneux */ public class WordGenerator { private static final char NULL_CHARACTER = 0; private static final Random RANDOM = new Random(); /** * @param arguments * @throws IOException */ public static void main(String[] arguments) throws IOException { String dictionaryPath = arguments[0]; int windowSize = Integer.parseInt(arguments[1]); int wordLength = Integer.parseInt(arguments[2]); int wordCount = Integer.parseInt(arguments[3]); WordGenerator wordGenerator = new WordGenerator(dictionaryPath, windowSize); int generatedWordCount = 0; while (generatedWordCount < wordCount) { System.out.println(wordGenerator.generateRandomWord(wordLength)); generatedWordCount++; } }
J'ai bien sûr essayé d'augmenter la taille d'arguments (encore qu'il me semble que 0 devrait donner une taille flexible ?) et ça ne change rien.Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at fr.guehenneux.wordgen.WordGenerator.main(WordGenerator.java:31)
Voici aussi la source à partir de laquelle j'essaye d'importer le projet : https://github.com/Achaaab/WordGenerator
Je vous remercie d'avance pour vos conseils.
Partager