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 ...
Broadcast receivers are app components that can register for system events or app events. When an event occurs, registered broadcast receivers are notified via an Intent . For instance, if you are implementing a media app and you're interested in knowing when the user connects or disconnects a headset, register for the ACTION_HEADSET_PLUG intent action. Use broadcast receivers to respond to messages that have been broadcast from apps or from the Android system. To create a broadcast receiver: Define a subclass of the BroadcastReceiver class and implement the onReceive() method. Register the broadcast receiver, either statically or dynamically. These steps are described below. Subclass a BroadcastReceiver To create a broadcast receiver, define a subclass of the BroadcastReceiver class. This subclass is where Intent objects are delivered if they match the intent filters you register for. Within your subclass: Implement t...
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