File tree 16 files changed +241
-1
lines changed
16 files changed +241
-1
lines changed Original file line number Diff line number Diff line change 10
10
" 5.ControlStatement\\ ifElse\\ ClassCodes" ,
11
11
" 6.String" ,
12
12
" 7.InputOutput" ,
13
- " 8,Method"
13
+ " 8.Method" ,
14
+ " 9.Array"
14
15
],
15
16
"java.debug.settings.onBuildFailureProceed" : true
16
17
}
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ package ClassCodes ;
2
+
3
+ public class methodDemo10 {
4
+
5
+ fun (){
6
+ System .out .println ("In fun..!" );
7
+ System .out .println ();
8
+ }
9
+ public static void main (String [] args ) {
10
+
11
+ methodDemo10 obj = new methodDemo10 ();
12
+
13
+ obj .fun ();
14
+
15
+ }
16
+ }
17
+
18
+
19
+ /*
20
+
21
+ methodDemo10.java:5: error: invalid method declaration; return type required
22
+ fun(){
23
+ ^
24
+ 1 error
25
+ error: compilation failed
26
+
27
+ */
Original file line number Diff line number Diff line change
1
+ package ClassCodes ;
2
+
3
+ public class methodDemo11 {
4
+
5
+ void (){
6
+ System .out .println ("In fun..!" );
7
+ System .out .println ();
8
+ }
9
+ public static void main (String [] args ) {
10
+
11
+ methodDemo11 obj = new methodDemo11 ();
12
+
13
+ // obj.fun();
14
+
15
+ }
16
+ }
17
+
18
+
19
+ /*
20
+
21
+ methodDemo11.java:5: error: <identifier> expected
22
+ void (){
23
+ ^
24
+ 1 error
25
+ error: compilation failed
26
+
27
+ */
Original file line number Diff line number Diff line change
1
+ package ClassCodes ;
2
+
3
+ public class methodDemo12 {
4
+
5
+ void fun (int x ){
6
+ System .out .println (x );
7
+ }
8
+ public static void main (String [] args ) {
9
+ methodDemo12 obj = new methodDemo12 ();
10
+
11
+ obj .fun (10 );
12
+ obj .fun (10.05f );
13
+ }
14
+ }
15
+
16
+
17
+ /*
18
+ .\methodDemo12.java:12: error: method fun in class methodDemo12 cannot be applied to given types;
19
+ obj.fun(10f);
20
+ ^
21
+ required: int
22
+ found: float
23
+ reason: argument mismatch; possible lossy conversion from float to int
24
+ 1 error
25
+ error: compilation failed
26
+ */
Original file line number Diff line number Diff line change
1
+ package ClassCodes ;
2
+
3
+ public class methodDemo13 {
4
+
5
+ void fun (float x ){
6
+ System .out .println (x );
7
+ }
8
+ public static void main (String [] args ) {
9
+ methodDemo13 obj = new methodDemo13 ();
10
+
11
+ obj .fun (10 );
12
+ obj .fun (10.05f );
13
+ obj .fun (true );
14
+ }
15
+ }
16
+
17
+
18
+ /*
19
+
20
+ methodDemo13.java:13: error: method fun in class methodDemo13 cannot be applied to given types;
21
+ obj.fun(true);
22
+ ^
23
+ required: float
24
+ found: boolean
25
+ reason: argument mismatch; boolean cannot be converted to float
26
+ 1 error
27
+ error: compilation failed
28
+
29
+ */
30
+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ package ClassCodes ;
2
+
3
+ public class methodDemo6 {
4
+
5
+ int y =90 ;
6
+ void fun (int x ){
7
+ System .out .println (x );
8
+ System .out .println (y );
9
+ }
10
+
11
+ public static void main (String [] args ) {
12
+ methodDemo6 obj = new methodDemo6 ();
13
+
14
+ obj .fun (10 );
15
+
16
+ System .out .println ("End of the main function...!" );
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ package ClassCodes ;
2
+
3
+ public class methodDemo7 {
4
+
5
+ void fun (){
6
+ System .out .println ();
7
+ }
8
+ public static void main (String [] args ) {
9
+
10
+ methodDemo7 obj = new methodDemo7 ();
11
+ obj .fun (x );
12
+
13
+ }
14
+ }
15
+
16
+
17
+ /*
18
+
19
+ Output:
20
+ .\methodDemo7.java:11: error: method fun in class methodDemo7 cannot be applied to given types;
21
+ obj.fun();
22
+ ^
23
+ required: int
24
+ found: no arguments
25
+ reason: actual and formal argument lists differ in length
26
+ 1 error
27
+ error: compilation failed
28
+
29
+
30
+
31
+ Second type:
32
+
33
+ .\methodDemo7.java:11: error: cannot find symbol
34
+ obj.fun(x);
35
+ ^
36
+ symbol: variable x
37
+ location: class methodDemo7
38
+ 1 error
39
+ error: compilation failed
40
+
41
+ */
Original file line number Diff line number Diff line change
1
+ package ClassCodes ;
2
+
3
+ public class methodDemo8 {
4
+
5
+ void fun (int x ){
6
+ System .out .println ("In fun..!" );
7
+ System .out .println (x );
8
+ }
9
+ public static void main (String [] args ) {
10
+
11
+ methodDemo8 obj = new methodDemo8 ();
12
+
13
+ obj .fun ('A' );
14
+
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ package ClassCodes ;
2
+
3
+ public class methodDemo9 {
4
+
5
+ void fun (char ch ){
6
+ System .out .println ("In fun..!" );
7
+ System .out .println (ch );
8
+ }
9
+ public static void main (String [] args ) {
10
+
11
+ methodDemo9 obj = new methodDemo9 ();
12
+
13
+ obj .fun (65 );
14
+
15
+ }
16
+ }
17
+
18
+
19
+ /*
20
+
21
+ methodDemo9.java:13: error: method fun in class methodDemo9 cannot be applied to given types;
22
+ obj.fun(65);
23
+ ^
24
+ required: char
25
+ found: int
26
+ reason: argument mismatch; possible lossy conversion from int to char
27
+ 1 error
28
+ error: compilation failed
29
+
30
+ */
Original file line number Diff line number Diff line change
1
+
2
+
3
+ package ClassCodeArray ;
4
+
5
+ public class program1 {
6
+ public static void main (String [] args ) {
7
+
8
+ int arr [];
9
+
10
+ arr = new int [4 ];
11
+
12
+ int arr2 [] = new int [0 ];
13
+
14
+ // arr2[0]=1;
15
+ // System.out.println(arr2[0]);
16
+
17
+
18
+ boolean ch [] = new boolean [5 ];
19
+
20
+ for (int i =0 ;i <ch .length ;i ++){
21
+ System .out .println (ch [i ]);
22
+ }
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments