Kotlin is a statically typed, open-source programming language that runs on the JVM and can be used anywhere Java is used today. It can be compiled using Java source code The most popular features of kotlin are: Kotlin is Concise: reduces the writing of the extra codes Compact code: Kotlin is an OOPs-based programming language. Less number of code compared to java. Kotlin is Simple: Compiling the code is simple, resulting in improved performance for Android development. Null safety: Kotlin is a null safety language. It aims to eliminate the NullPointerException (null reference) from the code. Java Interoperability: Kotlin provides full interoperability for Java code. Java code can utilize Kotlin code, and Kotlin code can use Java code. Compilation Time: Kotlin is faster and better than Java in terms of its performance and fast compilation time. Default & Named Parameters Difference between Val and Constant Both val and const ...
Coroutines are nothing but lightweight threads. Coroutines provide us an easy way to do synchronous and asynchronous programming. Coroutines allow execution to be suspended and resumed later at some point in the future which is best suited for performing non-blocking operations in the case of multithreading. Coroutines is a lightweight thread because creating coroutines doesn't allocate new threads. Instead, they use predefined thread pools, and smart scheduling. Scheduling is the process of determining which piece of work you will execute next.. Is called on suspending functions. We can suspend and resume the Coroutines while execution. This means we can have a long-running task, which can be executed one by one or which can be executed little-by-little.. We can pause it any number of times and resume it when we are ready again. Advantages/Properties : Run 1 background thread & Multiple Coroutines Light Weight Threads Can run in parallel Can wait for each other Communicate wi...
What is Stack? Stack is a linear data structure that follows the specific order to perform the operations. For example, if we want to access the element in the array we can do it any time but in the case of stack data structure, there is only one sequence to access the element. In the stack, we insert the element from one end with push operation and delete the element from the same end using pop operation. The end of the stack used to perform all the operations is called the top of the stack. Therefore, a stack follows the LIFO (Last In First Out) principle, which means the element that is inserted last will be the first element to come out of the stack. The most important thing to remember in the stack data structure is that it stores the elements of the same data type only. Let us understand the condition to check whether the stack is empty for full: Condition to Check if Stack is Empty int Empty() { if (top ==- 1 ) return 1 ; else return 0 ; } Con...
Comments
Post a Comment