The arrayList is defined as one of the kotlin collection that can be used to create the dynamic array the user may create additionally or removed the data at run time it automatically add or delete the datas in the list based on the requirement so based on this scenario the arrayList class...
import static org.mockito.Mockito.times; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.t...
Creating an array in JavaScript is easy. We create an array using the var keyword. It is similar to the way we create an Array using ArrayList in Java. Java insists on specifying the data type of the ArrayList. But in JavaScript, we do not explicitly declare the data type of the Array...
How does kclass Work in Kotlin? Generally, the kotlin class works with many scenarios to implement the application. We can use many methods to execute the user operations, and it can be called upon the main method with the help of the class object. The mapping and serialization of the kC...
To avoid this, prefer using Kotlin’s immutable collections. Instead of writing: vallist = arrayListOf<String>() Prefer writing: vallist = listOf<String>() While the first one is creating a mutable list, the second one will create a list without any methods to add or remove elements from...
Kotlin 2. Minimize Activity Leaks Activity leaks or memory leaks, in general, are extremely dangerous. How does it happen? If we keep a reference to an unused Activity in our code, we keep all of the Activity’s layout as well as its views. As a consequence, there are a lot of pixel...
Add Objects of the Same Type in an ArrayList Here, we will add user-defined or custom class objects to an ArrayList. In ArrayList, we can access the elements using the integer index. We’ll specify or declare the type of object we will store in the ArrayList inside the <> (angle brack...
In thePickerViewActivity.kt, declare two variables, theStringselectedItemto keep the selected item from the PickerView, and anIntselectedItemPositionfor the position. Also, initialize theBooleanstatusBarDark true= Dark status bar icons false= Light status bar icons ...
Channel, which represents a connection to the Ably channel through which messages are sent Channel.MessageListener, a functional interface an instance of which is provided by the developer to process incoming messagesThe general workflow with Ably.io in Kotlin looks like this:C#...
In Android, we have to give the permission to access the sandbox(Memory area) of another app. Before API 21 we just need to declare the permission in the android manifest file. For API 21 or higher we need to give the permission dynamically. In this tutorial, I am going to explain ho...