yes i think with newinstanse(); | 0 |
By: [email protected] On: Tue May 28 02:40:00 EDT 2013 5 0 0 | 5 |
Are You Satisfied :3Yes1No |
There are four different ways to create objects in java: A. Using new keyword This is the most common way to create an object in java. Almost 99% of objects are created in this way. MyObject object = new MyObject(); B. Using Class.forName() If we know the name of the class & if it has a public default constructor we can create an object in this way. MyObject object = (MyObject) Class.forName("subin.rnd.MyObject").newInstance(); C. Using clone() The clone() can be used to create a copy of an existing object. MyObject anotherObject = new MyObject(); MyObject object = anotherObject.clone(); D. Using object deserialization Object deserialization is nothing but creating an object from its serialized form. ObjectInputStream inStream = new ObjectInputStream(anInputStream ); MyObject object = (MyObject) inStream.readObject(); You can read from here | 0 |
By: [email protected] On: Tue May 28 03:20:31 EDT 2013 3 57 0 | 60 |
Are You Satisfied :1Yes2No |
You can create an object without new keyword and also you can access all methods with that object by writing code like below ClassName obj = (ClassName )Activator.CreateInstance(typeof(ClassName )); | 0 |
By: [email protected] On: Tue May 28 05:42:01 EDT 2013 0 392 0 | 392 |
Are You Satisfied :0Yes1No |