java - pass an object creat in the main of a class to another class -


i have class:

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; } } 

now use otherclass in main. how can do? class want use otherclass object created in class example before

public class myownmain { public static void main(string[] args) { // here need otherclass object created in example class } } 

the main functions in different classes represent different applications , won't able refer objects created in 1 application another.

in case want use similar objects in other main function have create new instances , use instead. not obvious though trying achieve.


Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -