This should work. You need to declare the variable cchild to be a static member of the JavaApplicaiton1 class to be able to access it statically.
class sample
{
public static int x;
public int y;
sample()
{
x=0;
}
}
public class JavaApplication1 {
// NEW BIT - by making this variable static we can now access it without needing an instance of the object.
static sample cchild=new sample();
public static void main(String[] args) {
sample.x=0;
cchild.x=9;
}
}
There a re a few other things you might do differently in this code example. The first is that I would suggest that you use the Java naming convention of starting the name of your classes with a capital letter (Sample instead of sample in this case) otherwise they do not look like class names to Java people.