我有这个类:传中,主要的类的对象科瑞到另一个类
public class Example
{
public void static main(String[] args)
{
Object obj = new Object();
OtherClass oc = new OtherClass(obj);
}
}
public class OtherClass
{
private Object object;
public OtherClass(Object ob)
{
this.object = ob;
}
}
现在我会在另一个主要使用OtherClass。我能怎么做? 这是我想使用的类实例创建OtherClass对象之前
public class myownmain
{
public static void main(String[] args)
{
// Here I need OtherClass object created in Example class
}
}
因此,基本上你正在运行2个应用程序,并且你想在它们之间传递数据?看看['Inter-process communication'](http://en.wikipedia.org/wiki/Inter-process_communication)。 – 2012-07-07 09:26:06
@ Eng.Fouad是的。这是我想要做的......但我失败了 – user1508419 2012-07-07 09:34:36