Bonjour,

Je suis en train de me former sur Java et j'ai un problème que je ne comprends pas
voici mon code:
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
 
// Dans Test.java
public class Test
{
  public static void main(String[] _args)
  {
    Statistic oStat = new Statistic();
    int x = oStat.average(10,20);
    System.out.println(x);
 
  }
}
 
// Dans Statistic.java
public class Statistic
{
  public int average(int... liste)
  {
  int sum=0;
 
  for (int x:liste)
  {
    sum += x;
  }
  return (int) ( sum / liste.length);
  }
 
  public float average(float... liste)
  {
  float sum=0;
 
  for (float x:liste)
  {
    sum += x;
  }
  return sum / liste.length;
  }
}
Le problème que je rencontre est que dans le programme principal sur la ligne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
int x = oStat.average(10,20);
Le compilateur indique cette erreur:
reference to average is ambiguous, both method average(int...) in Statistic and method average(float...) in Statistic match

Pourriez-vous m'aider?
Merci
Henri