One, package packet is a folder, the package under the class to each other to access such as a file.
Second, the class interior is equivalent to a Delphi CALSS, static functions can only access static functions.
Package mainpack;
public class Mainprg {
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
Human Aman=new Human ();
Human Bman=new Human ();
Aman. Createnewman ("Zhang San", +, True);
Bman. Getaman ();
Showstr (Bman.name);
}
private static void Showstr (String str) {
System.out.print (str);
}
}
Static variables are equivalent to a public access space, and new instances can still access data from other instances.
Package mainpack;
public class Human {
Static String Name=null;
static int age=0;
Static Boolean sex=true;
public void Createnewman (String nn,int Aa,boolean ss) {
Name=nn;
AGE=AA;
Sex=ss;
}
Public human Getaman () {
Human Hh=new Human ();
Hh.name=name;
Hh.age=age;
Hh.sex=sex;
return HH;
}
}
Results show Zhang San
Variable minus static, showing null
Super Simple example of the relationship between Java PACKET CLASS and variables