Skip to content

Commit e462336

Browse files
Banti ShawBanti Shaw
authored andcommitted
class, class constructor
1 parent 9da99ee commit e462336

10 files changed

+21
-22
lines changed

ClassConstEx11.class

1.08 KB
Binary file not shown.

ClassConstEx11.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package JavaEntry;
2+
3+
public class ClassConstEx11 { // Createing a class
4+
int x;
5+
String text;
6+
String total;
7+
8+
public ClassConstEx11(int y, String content){ // Createing a class constructor
9+
x = 10; // Assign value in class attribute
10+
total = content + x + y;
11+
}
12+
13+
public static void main(String[] args){
14+
ClassConstEx11 constObj = new ClassConstEx11(5, "The total value is "); // we can pass value to the constructor
15+
System.out.println(constObj.x);
16+
System.out.println(constObj.total);
17+
}
18+
19+
}

ClassEx10.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ public static void main(String[] args){
2424
System.out.println(classObj2.y);
2525

2626

27+
// Import class from another class
2728
ClassImportEx10 importClass = new ClassImportEx10();
2829
importClass.printMyName("Banti Shaw");
29-
30-
31-
32-
30+
3331
}
3432
}

ConditionEx5.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,5 @@ public static void main(String[] arg){
7171
System.out.println("Number is not a valid month");
7272
break;
7373
}
74-
75-
76-
77-
78-
7974
}
8075
}

DataTypeEx2.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,5 @@ public static void main(String[] arg){
5252
", the price of the product is " + productPrice +
5353
", so total amount will be " + totalPrice +
5454
", and the price need to pay in " + rupee);
55-
56-
5755
}
5856
}

EntryEx1.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,5 @@ public static void main(String[] arg){
4646
System.out.println("Addition - " + (x += y)); // x = x + y, here x is now 15;
4747
System.out.println("Multiply - " + (x *= y)); // x = x * y, as x is 15, now 15 * 5 = 75;
4848

49-
50-
51-
5249
}
5350
}

LoopEx7.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,4 @@ public static void main(String[] arg){
6363
System.out.println(i);
6464
}
6565
}
66-
6766
}

MethodEx9.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ static int recurFunc(int num){
3636
}
3737
}
3838

39-
4039
public static void main(String[] args){
4140
firstMethod();
4241
printMyName("Banti", 001);

StringEx4.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ public static void main(String[] arg){
1818
String speText = "If you have a some \"special's\" text in between text";
1919
System.out.println(speText);
2020

21-
2221
}
2322
}

TypeCastingEx3.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ public static void main(String[] arg){
1313
short getMarks = 450;
1414
float markPercent = (float) getMarks / passMarks * 100.0f; // Manual casting: short to float
1515
System.out.println(markPercent);
16-
17-
18-
19-
2016

21-
2217
}
2318
}

0 commit comments

Comments
 (0)