Assignment - Unit 2

.doc
School
University of the People**We aren't endorsed by this school
Course
CS 4405
Subject
Computer Science
Date
Jan 12, 2025
Pages
9
Uploaded by ColonelSummerMagpie10
CS 4405Mobile ApplicationsDaian GanUniversity of the People
Background image
CS 4405 Mobile Applications1Installing Android StudioI first went to Android Studio website and downloaded the installer.Then I double clicked on the installation file and drag the app to the Applications folder to be installed:
Background image
CS 4405 Mobile Applications2Then I followed the steps:
Background image
CS 4405 Mobile Applications3
Background image
CS 4405 Mobile Applications4
Background image
CS 4405 Mobile Applications5IntroductionAndroid development has become increasingly accessible with tools like Android Studio and programming languages like Kotlin, which are preferred over Java for their ease of use and modern features. This assignment explores the fundamentals of Kotlin, focusing on arrays and collections, and explains why Kotlin is the language of choice for Android development.Why Kotlin is Preferred Over JavaKotlin is preferred over Java due to its concise syntax, enhanced safety features, and 100% interoperability with Java. Kotlin reduces boilerplate code, offers null safety to prevent NullPointerException, and supports functional programming (Why Kotlin, n.d.). These features make it a "better Java" for developers, increasing productivity and reducing errors.Program: Concatenating Arrays in KotlinThe following Kotlin program demonstrates how to create two arrays—one with first names and another with corresponding last names—and concatenate them into a third array containing full names.fun main() {val firstNames = arrayOf("James", "Joseph", "Art")val lastNames = arrayOf("Bhatt", "Darakjy", "Veere")val fullNames = Array(firstNames.size) { i -> "${firstNames[i]} ${lastNames[i]}" }println("First Names: ${firstNames.joinToString(", ")}")println("Last Names: ${lastNames.joinToString(", ")}")println("Full Names: ${fullNames.joinToString(", ")}")}This code uses Kotlin's array functionalities to combine data efficiently. Below is a screenshot of the code and output in Kotlin online playground because my local machine has not enough resources to run:
Background image
CS 4405 Mobile Applications6You can review the code and test it in the following URL:https://pl.kotl.in/BkqWI0xMoTypes of Collections in KotlinCollections in Kotlin are broadly categorized into three types:1.ListA Listis an ordered collection that can contain duplicates. It can be mutable (MutableList) or immutable (List). Example:2.val fruits = listOf("Apple", "Banana", "Cherry")3.println(fruits) // Output: [Apple, Banana, Cherry]4.SetA Setis an unordered collection that contains unique elements. It also has mutable and immutable variants. Example:5.val uniqueNumbers = setOf(1, 2, 2, 3)6.println(uniqueNumbers) // Output: [1, 2, 3]
Background image
CS 4405 Mobile Applications77.MapA Mapis a collection of key-value pairs. Keys are unique, and each key maps to exactly one value. Example:8.val countryCodes = mapOf("US" to "United States", "IN" to "India")9.println(countryCodes["US"]) // Output: United StatesThese collections provide flexibility in managing data for Android applications.Pros and Cons of Becoming an Android DeveloperPros:High demand: The growing mobile industry ensures a steady demand for Android developers.Flexibility: Android is an open-source platform with extensive libraries and tools.Lucrative career: Developers earn competitive salaries due to specialized skills (Monnappa, 2022).Cons:Learning curve: Developers must stay updated with frequent technology updates.Platform fragmentation: Supporting a wide range of devices and OS versions can be challenging.ConclusionKotlin’s features, combined with Android Studio, make it a robust choice for Android app development. Understanding Kotlin’s array manipulation and collection types lays a strong foundation for building efficient applications (adityamshidlyali, 2021).
Background image
CS 4405 Mobile Applications8Referencesadityamshidlyali. (2021, July 7). A complete guide to learn kotlin for android app development. GeeksforGeeks.Monnappa, A. (2022, May 27). Are you future ready? Building a career in mobile app development. Simplilearn.Why Kotlin. (n.d.). Why Kotlin. kotlinlang. Retrieved June 15, 2022, from https://kotlinlang.org/#why-kotlin
Background image