Server-Side Kotlin-Array Methods

Search for a command to run...

No comments yet. Be the first to comment.
Synchronization is one of the most important concepts in Linux kernel development. When multiple kernel threads access a shared resource simultaneously, improper synchronization can lead to race condi

Modern software systems often separate control logic from high-performance execution logic. This design is common in networking, distributed systems, operating systems, storage engines, and embedded s

Introduction Engineering software often combines multiple programming languages to leverage their individual strengths. A common approach is to implement computational algorithms in native C or C++ wh

Deadlocks are one of the most common synchronization problems encountered in operating systems and concurrent programming. Although the concept is frequently introduced in textbooks, observing it insi

Memory and resource allocation are fundamental operations inside the Linux kernel. Whether assigning device IDs, managing CPU masks, allocating interrupt vectors, or tracking hardware resources, the k

This method returns 1st element from the given array.
>>>val languages = arrayOf<String>("java","python", "javascript","php")
>>>println(languages.componenet1())
java
This method returns 2,3 and 4th elements from the given array.

Returns the first element from the given array.
>>>println(languages.first())
java
Returns the last index number of elements from the given array.
>>>println(languages.lastIndexOf("php"))
3
Returns true if the array has no elements.
>>>println(languages.none())
false
//empty array
>>>val lang = arrayOf<String>()
>>>println(languages.none())
true
Returns a random element from the given array.
>>>println(languages.random())
php
Returns a list containing the first n elements.
>>>println(languages.take(2))
[java,python]
Returns true if the element is found in the array.
>>>println(languages.contains("javascript"))
true
Returns the total number of elements from the given array.
>>>println(languages.count())
4
Returns a list containing all elements except the first n elements.
>>>println(languages.drop(2))
[javascript, php]
code tested on kotlin REPL Kotlin version 1.7.21 (JRE 11.0.17+8-post-Ubuntu-1ubuntu220.04)