Skip to content

Commit 05093da

Browse files
committed
feat: Bugs fixed and info added.
Signed-off-by: https://github.com/Someshdiwan <someshdiwan369@gmail.com>
1 parent 36fd411 commit 05093da

File tree

3 files changed

+20
-32
lines changed

3 files changed

+20
-32
lines changed

Section8LoopAB/Loop 2.O/src/CountingError.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ static method named count that, Returns an int (the count), Takes a 2D array of
2323
return count;
2424
}
2525

26-
public static void main (String[]args) {
27-
String[][] items = {
28-
{"apple", "banana", "cherry"},
29-
{"dog", "cat", "rat"},
30-
{"hat", "bat", "mat"}
31-
};
32-
int result = count(items);
33-
System.out.println("Count of strings containing 'a': " + result);
34-
}
26+
public static void main (String[]args) {
27+
String[][] items = {
28+
{"apple", "banana", "cherry"},
29+
{"dog", "cat", "rat"},
30+
{"hat", "bat", "mat"}
31+
};
32+
int result = count(items);
33+
System.out.println("Count of strings containing 'a': " + result);
34+
}
3535
}

Section8LoopAB/src/ArithimaticSeries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static void main(String[] args) {
99
System.out.println("Enter a, d and n");
1010

1111
int a = sc.nextInt();
12-
int d= sc.nextInt();
12+
int d = sc.nextInt();
1313
int n = sc.nextInt();
1414

1515
int term = a;

Tips And Tricks/Note.txt

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ condition ? value_if_true : value_if_false
66

77
It is a compact if–else expression that returns a value.
88

9-
10-
119
Simple example
1210

1311
int a = 5;
@@ -24,9 +22,6 @@ if (a > b) {
2422
max = b;
2523
}
2624

27-
28-
29-
3025
In the context of the earlier discussion
3126

3227
There was no ternary operator used in the last Java code.
@@ -38,31 +33,24 @@ cost += (sDigit - tDigit + 10) % 10;
3833
does not contain ?.
3934
It uses modulo arithmetic, not a conditional operator.
4035

41-
42-
4336
When ? is typically used
44-
• Assigning values based on a condition
45-
• Returning one of two expressions
46-
• Compact logic where readability is preserved
37+
• Assigning values based on a condition
38+
• Returning one of two expressions
39+
• Compact logic where readability is preserved
4740

4841
Example:
4942

5043
String result = (x >= 0) ? "Positive" : "Negative";
5144

52-
53-
54-
5545
When NOT to use ?
56-
• Complex nested logic
57-
• Multiple statements
58-
• Situations where clarity suffers
59-
60-
46+
• Complex nested logic
47+
• Multiple statements
48+
• Situations where clarity suffers
6149

6250
Summary
63-
• ? is not a wildcard
64-
• ? is not optional
65-
• ? always pairs with :
66-
• Meaning: “if condition then this else that”
51+
• ? is not a wildcard
52+
• ? is not optional
53+
• ? always pairs with :
54+
• Meaning: “if condition then this else that”
6755

6856
End.

0 commit comments

Comments
 (0)