Skip to content

Commit 9f7d36b

Browse files
Methods in Java
1 parent aa4095d commit 9f7d36b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

31.Methods/Ch7 Methods.pdf

2.08 MB
Binary file not shown.

31.Methods/cwh_31_methods.java

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
public class cwh_31_methods {
2+
3+
static int logic(int x, int y){
4+
int z;
5+
if(x>y){
6+
z = x+y;
7+
}
8+
else {
9+
z = (x +y) * 5;
10+
}
11+
x = 566;
12+
return z;
13+
}
14+
15+
16+
public static void main(String[] args) {
17+
int a = 5;
18+
int b = 7;
19+
int c;
20+
// Method invocation using Object creation
21+
//cwh_31_methods obj = new cwh_31_methods();
22+
//c = obj.logic(a, b);
23+
c = logic(a, b);
24+
System.out.println(a + " "+ b);
25+
int a1 = 2;
26+
int b1 = 1;
27+
int c1;
28+
c1 = logic(a1, b1);
29+
System.out.println(c);
30+
System.out.println(c1);
31+
}
32+
}

0 commit comments

Comments
 (0)