I wonder what happens when I assign a static object to non-static object ?
For example:
public class Test{
public void test(){
BoneCp cp=BoneCpLoad.getBoneCpPool();
}
}
public class BoneCpLoad{
private static BoneCpPool pool =new BoneCpPool();
public static BoneCp getBoneCpPool(){
return pool;
}
}
Static objects actually don’t exist.
In this case static keyword is referred to getBoneCpPool() method. This is perfectly legal and the static method returns an instance of BonceCp object.
static modifier keyword can be applied to methods, and denotes methods that not belong to a particular instance of a class, but to the class itself.
static modifier keyword can be applied to fields too (actually are static reference to objects). In this case denotes fields that not belong to a particular instance of a class, but are share between all class instances of the same type.