Skip to content

Commit a9e6daa

Browse files
committed
added git ignore file
1 parent 0ffecf3 commit a9e6daa

4 files changed

Lines changed: 79 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.class

Method.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import java.util.*;
2+
3+
public class Method {
4+
public static void main(String[] args) {
5+
System.out.println("Calling Simple Method");
6+
simpleMethod();
7+
}
8+
9+
public static void simpleMethod() {
10+
System.out.println("Simple Method");
11+
}
12+
}

ParamMethod1.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.*;
2+
3+
// Call by Value
4+
5+
public class ParamMethod1 {
6+
public static void main(String[] args) {
7+
int a = 10;
8+
int b = 20;
9+
10+
System.out.println("Before swapping, a: " + a + " b: " + b);
11+
12+
// Invoke the swap method
13+
swapFunction(a, b);
14+
System.out.println("After swapping(outside), a: " + a + " b: " + b);
15+
}
16+
17+
public static void swapFunction(int a, int b) {
18+
System.out.println("Before swapping(Inside), a: " + a + " b: " + b);
19+
20+
// Swap n1 with n2
21+
int c = a;
22+
a = b;
23+
b = c;
24+
25+
System.out.println("After swapping(Inside), a: " + a + " b: " + b);
26+
}
27+
}

StaticModifier.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import java.util.*;
2+
3+
public class StaticModifier {
4+
// Static Variables
5+
public static int a = 10;
6+
public static int b = 20;
7+
8+
public static void sum() {
9+
// Local variable to sum function
10+
int z = a + b;
11+
12+
System.out.println("Sum: " + z);
13+
}
14+
15+
public void diff() {
16+
// Local variable to diff function
17+
int z = a - b;
18+
19+
a = 100;
20+
b = 200;
21+
22+
System.out.println("Diff: " + z);
23+
}
24+
25+
public static void main(String[] args) {
26+
// Instance of the class
27+
StaticModifier obj = new StaticModifier();
28+
29+
// Access static variables
30+
System.out.println("a: " + a);
31+
System.out.println("b: " + b);
32+
33+
// Call the sum function
34+
sum();
35+
36+
// Call the diff function
37+
obj.diff();
38+
}
39+
}

0 commit comments

Comments
 (0)