Co-writer: Aseem Garg

Android app crash is not a recent issue. It has been with us since the launch of Android and has affected many users since then. It can be caused by hardware problems, cache data issue, poor code implementation or any other thing.

Why does an app crash?

An app is a simple software that allows you to perform specific tasks. These software are written using programming languages like Java and has thousands of lines of execution. …

Collections: Maps, HashMap, List, Set

What are the collections?

Well, as the name suggests Collections are the group of the same objects or the objects of the same type.

There are generally 3 types of collections we use in Koltin —

  1. List — List is an ordered collection with access to elements by indices (integer numbers that reflect their position). Elements can occur more than once in a list. An example of a list is a sentence: it’s a group of words, their order is important, and they can repeat. Eg — listOf(“I”, “love”, “Kotlin” )
  2. Set — Set is a collection of unique elements. It reflects the mathematical…

What are Generics?

Generics allows us to declare a type (Integer, String, User-defined types, ..etc) to be a parameter of a class or method.


Some classes that implement Generics are:

  1. HashMap<String> ✔️
  2. ArrayList<Integer> ✔️
  3. Set<Integer> .. etc ✔️

Defining primitive types to Generics is not possible, We have to pass Objects or Wrappers while defining our classes, methods or interface. For Eg:

  1. HashMap<int> ❌
  2. ArrayList<char> ❌

How to declare Generics?

class Box<T>(t: T) {
var value = t

Variance in Java and Kotlin

Have you ever wondered why Java needs those strange wildcards like

  1. ? — This wildcard allows all types of the variable
  2. ? extends T — Wildcard with…

What are sealed classes?

Sealed classes are used for representing restricted class hierarchies, when a value can have one of the types from a limited set, but cannot have any other type. They’re an extension of enum classes.

To declare a sealed class sealed” modifier is used before the class name. A sealed class can have subclasses, but all of them must be declared in the same file as the sealed class itself. Though this was restricted in older versions of Koltin, in older versions to declare a sealed subclass, that can only be done using nesting. (Nested Classes)

How to declare a sealed class?

sealed class Color()

Difference between enum and sealed classes

Enum class…


SDE - II @Internshala | Mentor @ hackCBS 2.0 | Full Stack Developer | Freelancer | Open-Source Contributer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store