File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -2636,6 +2636,7 @@ StringBuffer: World
2636
2636
#### Q. *** How can we create a object of a class without using new operator?***
2637
2637
Different ways to create an object in Java
2638
2638
* ** Using new Keyword**
2639
+
2639
2640
``` java
2640
2641
class ObjectCreationExample {
2641
2642
String Owner ;
@@ -2649,6 +2650,7 @@ public class MainClass {
2649
2650
2650
2651
```
2651
2652
* ** Using New Instance (Reflection)**
2653
+
2652
2654
``` java
2653
2655
class CreateObjectClass {
2654
2656
static int j = 10 ;
@@ -2682,6 +2684,7 @@ class MainClass {
2682
2684
2683
2685
```
2684
2686
* ** Using Clone**
2687
+
2685
2688
``` java
2686
2689
class CreateObjectWithClone implements Cloneable {
2687
2690
@Override
@@ -2713,6 +2716,7 @@ class MainClass {
2713
2716
}
2714
2717
```
2715
2718
* ** Using ClassLoader**
2719
+
2716
2720
``` java
2717
2721
class CreateObjectWithClassLoader {
2718
2722
static int j = 10 ;
You can’t perform that action at this time.
0 commit comments