Skip to content

Commit c459ce7

Browse files
committed
Updated README.md
1 parent 0d5969b commit c459ce7

File tree

1 file changed

+94
-5
lines changed

1 file changed

+94
-5
lines changed

README.md

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
![preview](preview/preview-2.png)
3434

3535
```bash
36-
avinashbest $ javac Main.java
36+
avinashbest/ $ javac Main.java
3737
```
3838

3939
```bash
40-
avinashbest $ cd ..
40+
avinashbest/ $ cd ..
4141
```
4242

4343
```bash
44-
$ java com.avinashbest.Main
44+
src/ $ java com.avinashbest.Main
4545
```
4646

4747
## Interesting Facts about Java:
@@ -285,7 +285,7 @@
285285
System.out.println("You are " + age);
286286
System.out.println("Your name " + name);
287287
}
288-
}
288+
}
289289
```
290290

291291
## Mortgage Calculator:
@@ -315,4 +315,93 @@
315315
System.out.println("Mortgage: " + NumberFormat.getCurrencyInstance().format(mortgage));
316316
}
317317
}
318-
```
318+
```
319+
320+
## Comparison Operators:
321+
322+
```bash
323+
public class Main {
324+
public static void main(String[] args) {
325+
int x = 1;
326+
int y = 1;
327+
System.out.println(x == y);
328+
System.out.println(x != y);
329+
System.out.println(x > y);
330+
System.out.println(x >= y);
331+
System.out.println(x < y);
332+
System.out.println(x <= y);
333+
}
334+
}
335+
```
336+
337+
## Logical Operators:
338+
339+
```bash
340+
public class Main {
341+
public static void main(String[] args) {
342+
int temperature = 22;
343+
boolean isWarm = temperature > 20 && temperature < 30;
344+
System.out.println(isWarm);
345+
346+
boolean hasHighIncome = true;
347+
boolean hasGoodCredit = true;
348+
boolean hasCriminalRecord = false;
349+
boolean isEligible = (hasGoodCredit || hasHighIncome) && !hasCriminalRecord;
350+
System.out.println(isEligible);
351+
}
352+
}
353+
```
354+
355+
## if-statement:
356+
357+
```bash
358+
public class Main {
359+
public static void main(String[] args) {
360+
int temperature = 32;
361+
if (temperature > 32) {
362+
System.out.println("It's a hot day");
363+
System.out.println("Drink water");
364+
} else if (temperature > 20) {
365+
System.out.println("Beautiful day");
366+
} else {
367+
System.out.println("Cold day");
368+
}
369+
/*Simplifying if-statement*/
370+
int income = 120_000;
371+
boolean hasHighIncome;
372+
if (income > 100_000) {
373+
hasHighIncome = true;
374+
} else {
375+
hasHighIncome = false;
376+
}
377+
/*Above Expression can be simplified by professional be like*/
378+
int income = 120_000;
379+
boolean hasHighIncome = income > 100_000;
380+
}
381+
}
382+
```
383+
384+
# Ternary Operators:
385+
386+
```bash
387+
public class Main {
388+
public static void main(String[] args) {
389+
int income = 120_000;
390+
String className;
391+
if (income > 100_000) {
392+
className = "First";
393+
} else {
394+
className = "Economy";
395+
}
396+
/*Simplification can be done as*/
397+
income = 120_000;
398+
className = "Economy";
399+
if (income > 100_000) {
400+
className = "First";
401+
}
402+
/*More Simplification can be done using Ternary Operator*/
403+
income = 120_000;
404+
className = (income > 100_000) ? "First" : "Economy";
405+
}
406+
}
407+
```

0 commit comments

Comments
 (0)