j'ai créer deux fichiers
le premier classepoint.java
Citation:
import b.*;
public class classepoint {
public static void main(String[] args) {
point d=new point (3,4);
point e=new point (5,6);
point z=new point (1,2);
int surf;
z.somme(d,e);
surf=z.surface();
System.out.println(z.abcisse());
System.out.println(z.ordonne());
System.out.println("la surface est : " + surf);
System.out.println("Hello World!");
}
}
à la compilation les erreurs:
Citation:
C:\Users\jm18c>javac *.java
classepoint.java:6: error: cannot find symbol
point d=new point (3,4);
^
symbol: class point
location: class classepoint
classepoint.java:6: error: cannot find symbol
point d=new point (3,4);
^
symbol: class point
location: class classepoint
classepoint.java:7: error: cannot find symbol
point e=new point (5,6);
^
symbol: class point
location: class classepoint
classepoint.java:7: error: cannot find symbol
point e=new point (5,6);
^
symbol: class point
location: class classepoint
classepoint.java:8: error: cannot find symbol
point z=new point (1,2);
^
symbol: class point
location: class classepoint
classepoint.java:8: error: cannot find symbol
point z=new point (1,2);
^
symbol: class point
location: class classepoint
6 errors
et j'aii créer un dossier b
et j'ai mis le package
Citation:
package b;
public class point {
private int a,b;
point(int x,int y)
{
this.a=x;
this.b=y;
}
public void somme(point p1, point p2)
{
this.a=p1.a+p2.a;
this.b=p1.b+p2.b;
}
jai des erreurs
Citation:
b.java:3: error: class point is public, should be declared in a file named point.java
public class point {
^
1 error
c:/---------utilisateurs---------------1m18c------------------classepoint.java
c:/---------utilisateurs---------------1m18c-----------------------b-----------------------b.java