Skip to content

Commit 644ecee

Browse files
main
1 parent a2a8ce5 commit 644ecee

File tree

10 files changed

+142
-10
lines changed

10 files changed

+142
-10
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
"6.String",
1212
"7.InputOutput",
1313
"8,Method"
14-
]
14+
],
15+
"java.debug.settings.onBuildFailureProceed": true
1516
}

1.DataType/.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package PractiseCodes;
22
class Demo{
33

4-
public void main(String[] args){
4+
public static void main(String[] args){
55

66
// float var1 = 12.5f;
77
// // float var2 = 23.5f;
88

99
// System.out.println(var1);
10+
System.out.println("He");
1011
}
1112
}

3.Array/LeetCode/program38.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static int[] getConcatenation(int[] nums) {
4444
for(int i=0;i<nums.length;i++){
4545
res[i] = nums[j];
4646
res[2*i+nums.length-i] = nums[j];
47-
j++;
47+
j++;
4848
}
4949

5050
return res;

7.InputOutput/ClassCodes/program15.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ public static void main(String[] args) {
1515

1616
while(st.hasMoreElements()){
1717

18-
System.out.println(st.nextElement());
18+
System.out.println( st.nextElement().getClass().getClassLoader());
19+
20+
// st.nextElement().getClass().getClassLoader();
1921
}
2022
}
2123
}

8,Method/ClassCodes/program1.java renamed to 8,Method/ClassCodes/methodDemo1.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
package ClassCodes;
33

4-
public class program1 {
4+
public class methodDemo1 {
55

66
int x =10;
77
static void fun(){
@@ -15,9 +15,10 @@ void gun(){
1515

1616
public static void main(String[] args) {
1717

18-
program1 obj = new program1();
18+
methodDemo1 obj = new methodDemo1();
1919

20-
gun();
20+
obj.gun();
21+
// gun();
2122
}
2223
}
2324

8,Method/ClassCodes/methodDemo2.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
3+
package ClassCodes;
4+
public class methodDemo2 {
5+
6+
static int x =10;
7+
int y=20;
8+
9+
static void gun(){
10+
System.out.println("Inside Gun method...!");
11+
}
12+
13+
void fun(){
14+
System.out.println("Inside fun method...!");
15+
}
16+
17+
public static void main(String[] args) {
18+
19+
gun();
20+
System.out.println(x);
21+
22+
System.out.println("After creating the object ");
23+
24+
methodDemo2 obj = new methodDemo2();
25+
26+
obj.fun();
27+
System.out.println(obj.y);
28+
}
29+
}

8,Method/ClassCodes/methodDemo3.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package ClassCodes;
2+
3+
public class methodDemo3 {
4+
5+
int x=10;
6+
static final int z =90;
7+
8+
static int y=20;
9+
10+
void fun(){
11+
System.out.println(x);
12+
System.out.println(y);
13+
// System.out.println(z);
14+
15+
}
16+
public static void main(String[] args) {
17+
18+
methodDemo3 obj = new methodDemo3();
19+
20+
obj.fun();
21+
System.out.println(z);
22+
}
23+
}

8,Method/ClassCodes/methodDemo4.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package ClassCodes;
2+
3+
import java.io.BufferedReader;
4+
import java.io.InputStreamReader;
5+
6+
public class methodDemo4 {
7+
8+
static int add(int a,int b){
9+
return a+b;
10+
}
11+
12+
static int sub(int a,int b){
13+
return a-b;
14+
}
15+
16+
static int mult(int a,int b){
17+
return a*b;
18+
}
19+
20+
static int div(int a,int b){
21+
return a/b;
22+
}
23+
24+
public static void main(String[] args)throws Exception {
25+
26+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
27+
28+
System.out.println("Enter the two numbers: ");
29+
int a = Integer.parseInt(br.readLine());
30+
int b = Integer.parseInt(br.readLine());
31+
32+
System.out.println("Addition: "+add(a, b));
33+
System.out.println("Subtraction: "+sub(a, b));
34+
System.out.println("Multiplication: "+mult(a, b));
35+
System.out.println("Division: "+div(a, b));
36+
}
37+
}

8,Method/ClassCodes/methodDemo5.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package ClassCodes;
2+
3+
import java.io.BufferedReader;
4+
import java.io.InputStreamReader;
5+
6+
public class methodDemo5 {
7+
8+
static int add(){
9+
return a+b;
10+
}
11+
12+
13+
public static void main(String[] args)throws Exception {
14+
15+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
16+
17+
System.out.println("Enter the two numbers: ");
18+
int a = Integer.parseInt(br.readLine());
19+
int b = Integer.parseInt(br.readLine());
20+
21+
System.out.println("Addition: "+add());
22+
}
23+
}
24+
25+
26+
/*
27+
28+
.\methodDemo5.java:9: error: cannot find symbol
29+
return a+b;
30+
^
31+
symbol: variable a
32+
location: class methodDemo5
33+
.\methodDemo5.java:9: error: cannot find symbol
34+
return a+b;
35+
^
36+
symbol: variable b
37+
location: class methodDemo5
38+
2 errors
39+
error: compilation failed
40+
41+
*/

0 commit comments

Comments
 (0)