This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val stringObject: String = "Erselan Khan" | |
val stringNullObject: String? = null | |
/* | |
First start with non-null object | |
*/ | |
val value = stringObject.equals("Erselan Khan") | |
println("vale: $value") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HandleNullObjectJava { | |
public static void main(String[] args) { | |
String object = "Erselan Khan"; | |
String nullObject = null; | |
// Accessing both objects | |
/* | |
First Start with non-null object | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
/* | |
1. for loop using "in" | |
*/ | |
for(i in 0..5) { | |
println("for loop using in") | |
} | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
public class LoopsInJava { | |
public static void main(String[] args) { | |
List<String> list = new ArrayList<>(); | |
list.add("Erselan"); | |
list.add("Khan"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
/* | |
when -> with Enum value | |
*/ | |
val state = State.values().random() | |
printState(state) | |
/* | |
when -> with Int value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
public class MultiConditionsInJava { | |
public static void main(String[] args) { | |
/* | |
switch case -> with Enum value | |
*/ | |
State state = State.NOT_STARTED; | |
switch (state) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
/* | |
using val, to assign value only one time | |
*/ | |
val assignValueOnlyOneTime = "Erselan Khan" | |
assignValueOnlyOneTime = "" | |
/* | |
using var, to assign value multiple times |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KeywordsJava { | |
public static void main(String[] args) { | |
/* | |
using final, to assign value only one time | |
*/ | |
final String nonChangeableVariable = "Erselan Khan"; | |
nonChangeableVariable = "Arsalan Khan"; | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
// string value | |
var stringValue: String = "Erselan Khan" | |
println("String value $stringValue") | |
// int value | |
var intValue: Int = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
/* | |
Simple object initialization | |
*/ | |
val objectInitialization = ObjectInitialization() | |
objectInitialization.printMyName("Erselan Khan") | |
objectInitialization.addTwoNumbers(firstNumber = 2, secondNumber = 2) | |
} |
OlderNewer