Bonjour à tous et à toutes je suis un débutant en Java j'ai un souci avec 2 programmes.
Voici le code du premier :
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
| class ident
{ public ident()
{numcour++;
num=numcour;
}
public int getident(){return num;}
public static int getidentmax(){return numcour-1;}
private int num;
private static int numcour= Clavier.lireInt();
static{
System.out.println("donnez le 1er identificateur : ");
do numcour= Clavier.lireInt();
while (numcour<=0);
}
}
public class tstident1
{
public static void main(String[] args)
{ ident a= new ident(); ident b=new ident();
System.out.println("numero de a: "+a.getident());
System.out.println("numero de b: "+b.getident());
System.out.println("numero de : "+ident.getidentmax());
ident c = new ident();
System.out.println("numero de a: "+ident.getidentmax());
}
} |
le message d'erreur est :
C:\revision>javac tstident1.java
tstident1.java:1: error: cannot find symbol
import static java.lang.Clavier.*;
^
symbol: class Clavier
location: package java.lang
tstident1.java:13: error: cannot find symbol
private static int numcour= Clavier.lireInt();
^
symbol: variable Clavier
location: class ident
tstident1.java:17: error: cannot find symbol
do numcour= Clavier.lireInt();
^
symbol: variable Clavier
location: class ident
3 errors
Le code du 2eme:
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
| class point
{public point(int abs, int ord){x=abs; y=ord;}
public void affiche()
{System.out.println("coordonnees "+x+" "+y);
}
public static point maxnorm(point a, point b)
{double na=a.x*a.x+a.y*a.y;
double nb=b.x*b.x+b.y*b.y;
if(na>nb) return a;
else return b;
}
private double x;
private double y;
}
public class maxnorme
{
public static void main(String[] args)
{ point p1=new point(2,5);System.out.println("p1 :"); p1.affiche();
point p2=new point(3,1);System.out.println("p2 :"); p2.affiche();
point p=point.maxnorme(p1,p2);
System.out.println("Max de p1 et de p2 :"); p.affiche();
}
} |
à peu près c'est le meme message d'erreur
C:\revision>javac maxnorme.java
maxnorme.java:26: error: cannot find symbol
point p=point.maxnorme(p1,p2);
^
symbol: method maxnorme(point,point)
location: class point
1 error
besoin de votre aide!!
Merci!
Partager