Re: package und static classes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Szin schreef:
Hi!
Im new to Java and hav a Problem compiling a package:
To Simplest classes are in my package. When ich try to compile the
second it gave me a "Cannoc find symbol : variable MyTestClass"
pointing to the MyTestClass behind "double z="
Any suggestions? How can i declare that MyTestClass is not a variable
but a static class?
Tnx,
Andr??
// File mypackage\MyTestClass
public class MyTestClass
{
static public double myTestAdd( double a, double b )
{
return a+b;//z;
}
}
// FIle mypackage\MyWebServiceClass2
package mypackage;
public class MyWebServiceClass2
{
public double myWebServiceAdd( double a, double b )
{
double z = MyTestClass.myTestAdd(a,b);//MyJNIClass.myJNIAdd(a, b);
return z;
}
}
You need to import MyTestClass into this class, or use its fully
qualified name. That is, either
// FIle mypackage\MyWebServiceClass2
package mypackage;
// THIS
import mypackage.MyTestClass;
public class MyWebServiceClass2
{
public double myWebServiceAdd( double a, double b )
{
double z = MyTestClass.myTestAdd(a,b);//MyJNIClass.myJNIAdd(a, b);
return z;
}
}
or
// FIle mypackage\MyWebServiceClass2
package mypackage;
public class MyWebServiceClass2
{
public double myWebServiceAdd( double a, double b )
{
//THIS
double z =
mypackage.MyTestClass.myTestAdd(a,b);//MyJNIClass.myJNIAdd(a, b);
return z;
}
}
HTH, H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFF3BN1e+7xMGD3itQRAk7wAJ4l9MGywsppLhuibjp2I8ER6BpDjwCcCCjV
ZmlrRcoHTGkXETPsE7XBVVU=
=fgJK
-----END PGP SIGNATURE-----