File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class constructorchain {
2
+ public constructorchain (int a ,int b ){
3
+ System .out .println (a +b );
4
+ }
5
+ public constructorchain (int a ,int b ,int c ){
6
+ this (5 ,5 );
7
+ System .out .println (a +b +c );
8
+ }
9
+ public constructorchain (String a ,String b ){
10
+ this (5 ,5 ,5 );
11
+ System .out .println (a +b );
12
+ }
13
+
14
+ public constructorchain (double a ,double b ){
15
+ this ("hello" ,"world" );
16
+ System .out .println (a +b );
17
+ }
18
+ public static void main (String [] args ){
19
+ constructoroverload c1 =new constructorchain (10.0 ,20.0 );
20
+
21
+ }
22
+
23
+ }
Original file line number Diff line number Diff line change
1
+ public class constructoroverload {
2
+ public constructoroverload (int a ,int b ){
3
+ System .out .println (a +b );
4
+ }
5
+ public constructoroverload (int a ,int b ,int c ){
6
+ System .out .println (a +b +c );
7
+ }
8
+ public constructoroverload (String a ,String b ){
9
+ System .out .println (a +b );
10
+ }
11
+
12
+ public constructoroverload (double a ,double b ){
13
+ System .out .println (a +b );
14
+ }
15
+ public static void main (String [] args ){
16
+ constructoroverload c1 =new constructoroverload (10.0 ,20.0 );
17
+ constructoroverload c2 =new constructoroverload (10 ,20 ,30 );
18
+ constructoroverload c3 =new constructoroverload ("hello" , "world" );
19
+ constructoroverload c4 =new constructoroverload (10 , 20 );
20
+ }
21
+
22
+ }
You can’t perform that action at this time.
0 commit comments