public class First {
public static class Contents{
public void getStr(){
System.out.println("First.str="+str);
}
}
private static String str="hello!";
private void sayHi()
{
System.out.println("Hi!");
}
/
public class Contents2{
public void getStr(){
System.out.println("First.str="+str2);
}
}
private String str2="hello2!";
private void tryContents2()
{
Contents2 obj=new Contents2();
obj.getStr();
}
public static void main(String[] args)
{
System.out.println("Hello World!");
Contents obj=new Contents();
obj.getStr();
First f=new First();
f.sayHi();
f.tryContents2();
}
}
/*
Hello World!
First.str=hello!
Hi!
First.str=hello2!
请按任意键继续. . .
*/