
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1952 Articles for Apps/Applications

7K+ Views
const KeywordThe const keyword is used in Kotlin whenever the variable value remains const throughout the lifecycle of an application. It means that const is applied only on immutable properties of the class. In simple words, use const to declare a read-only property of a class.There are some constraints that are applied to the const variable. They are as follows −const can only be applied to the immutable property of a class.It cannot be assigned to any function or any class constructor. It should be assigned with a primitive data type or String.The const variable will be initialized at compile-time.ExampleIn ... Read More

10K+ Views
Kotlin library provides two different access modifiers for property declaration.In this article, we will highlight the difference between these two access modifiers and how we can use them in our application.LateinitIn order to create a "lateInit" variable, we just need to add the keyword "lateInit" as an access modifier of that variable. Following are a set of conditions that need to be followed in order to use "lateInit" in Kotlin.Use "lateInit" with a mutable variable. That means, we need to use "var" keyword with "lateInit"."lateInit" is allowed only with non-NULLable data types."lateInit" does not work with primitive data types."lateInit" can ... Read More

3K+ Views
Any variable which is initialized after its declaration is known as a "late initialized variable". In conventional programming languages, any non-NULL type of variable need to be initialized in the constructor. But sometimes, by mistake, developers forget to do these NULL checks which causes a programming error. In order to avoid this situation, Kotlin introduced a new modifier called as "lateInit". Along with this modifier, Kotlin provides a couple of methods to check whether this variable is initialized or not.In order to create a "lateInit" variable, we just need to add the keyword "lateInit" as an access modifier of that ... Read More

445 Views
In Java, "static" keyword is used for efficient memory management. Once a variable or method is declared as static, then the JVM will allocate memory for these variable only once. Usually static variables are used to declare common properties of a class, for example, "Name of the institution". In the following example, we will see how to use the static keyword.Example of Static in using JavaIn order to demonstrate how static works in Java, we will access our online Java compiler and we will create a Test class. Inside Test, we will try to create a static variable along with ... Read More

1K+ Views
Exception is an important aspect of any programming language. It prevents our code from generating incorrect output at runtime.The concept of exception in Kotlin is very much same as it is in Java. All the exceptions in Kotlin are the descendants of Throwable class. In Kotlin, developers do have the privilege to create their own custom Exception.Custom Exceptions are a part of unchecked exceptions which means they will be thrown at the runtime.Before getting into custom exceptions in Kotlin, let's take a look checked and unchecked exceptions.Checked ExceptionsChecked exceptions are those which are checked at the compile time. In the ... Read More

3K+ Views
A Map is a collection where data is stored as a key-value pair and the corresponding key has to be unique. A HashMap is a collection class based upon MutableMap interface and it does that by implementing MutableMap interface of HashTable. Kotlin provides four types of constructor to define and manipulate HashMap.HashMap() – It is the default constructor which helps us create an empty HashMap.HashMap(initialCapacity: Int, loadFactor: Float = 0f) – It helps us create a HashMap using initial capacity; if it is not provided, then it will be ignored and it will act as default HashMap().HashMap(initialCapacity: Int) – It ... Read More

3K+ Views
This example demonstrates how to change a TextView's style at runtime in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code in res/values/styles.xml bold|italic #FFFFFF normal #C0C0C0 Step 4 − Add the following code in res/values/colors.xml @android:color/holo_green_light @android:color/holo_red_dark Step ... Read More

2K+ Views
This example demonstrates how to send a notification from a service in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.ktimport android.content.Intent import android.os.Bundle import android.view.View import android.widget.EditText import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat class MainActivity : AppCompatActivity() { lateinit var editText: EditText override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) ... Read More

763 Views
This example demonstrates how to use glide to download an image into a bitmap using KotlinStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.ktimport android.graphics.Bitmap import android.graphics.drawable.Drawable import android.os.Bundle import android.widget.ImageView import androidx.annotation.Nullable import androidx.appcompat.app.AppCompatActivity import com.bumptech.glide.Glide import com.bumptech.glide.request.target.CustomTarget import com.bumptech.glide.request.transition.Transition; class MainActivity : AppCompatActivity() { lateinit var imageView: ImageView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) ... Read More

345 Views
This example demonstrates how to disable GridView scrolling in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.ktimport android.content.Context import android.os.Bundle import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.widget.* import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { private lateinit var gridView: GridView var imageIDs = arrayOf( R.drawable.ronaldo, R.drawable.andre, ... Read More