Bonjour,


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
import java.util.*;
 
public class Notes{
    private List<float> tabNotes;
 
    public Notes(){
	tabNotes=new ArrayList<float>();
    }
 
    public void ajouteNote(float n){
	tabNotes.add(n);
    }
 
    public float moyenne(){
	float res=0f;
	for(float i: tabNotes)
	    res+=i;
	return(res/tabNotes.size());
    }
 
    public String toString(){
	return "Moyenne:"+moyenne();
    }
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
import java.util.*;
 
public class Test{
public static void main(String[] args){
    Notes note=new Notes();
    note.ajouteNote(12);
    note.ajouteNote(13);
    note.ajouteNote(14);
    System.out.println(note);
  }
}
voilà il me sort sa en compilant:
Test.java:5: <identifier> expected
note.ajouteNote(12);
^
Test.java:5: illegal start of type
note.ajouteNote(12);
^
Test.java:6: <identifier> expected
note.ajouteNote(13);
^
Test.java:6: illegal start of type
note.ajouteNote(13);
^
Test.java:7: <identifier> expected
note.ajouteNote(14);
^
Test.java:7: illegal start of type
note.ajouteNote(14);
^
Test.java:8: <identifier> expected
System.out.println(note);
^
Test.java:8: <identifier> expected
System.out.println(note);

je ne comprend pas pourquoi?

Merci d'avance pour votre aide