This document provides tips and tricks for installing Kotlin programming tools and covers fundamental Kotlin concepts like data types, variables, functions, control flow structures, and loops. It discusses installing Kotlin and resolving common errors. It introduces basic Kotlin syntax for strings, numbers, Booleans, arrays, and more. It also covers if/else expressions, when expressions, enums, loops like while, for, and for-each, and break/continue functionality. The document encourages practicing exercises to continue learning Kotlin.
Npm : 201243501228
Nama : Syahroni
Kelas : R7H
Mata Kuliah : Komputer Grafik
Dosen : Nahot Frastian , M.Kom
Program Studi : Teknik Informatika
Universitas : Universitas Indraprasta Pgri
Program Komputer Grafik :
- Bintang
Input :
import javax.swing.* ;
import java.applet.Applet ;
import java.awt.Graphics ;
import java.awt.Color ;
public class bintang extends java.applet.Applet {
public void paint ( Graphics g ) {
// -200
//ini buat String tulisan kata
g.drawString ( " Komputer Grafik : Polygon Bintang ",80,370);
g.drawString ( " Nama : Syahroni ",80,400);
g.drawString ( " Npm : 2012 4350 1228 ",80,430);
g.drawString ( " Kelas : R7H ",80,460);
g.drawString ( " Mata Kuliah : Komputer Grafik ",80,490);
g.drawString ( " Dosen : Nahot Frastian ,M.kom ",80,520);
g.drawString ( " Program Studi : Teknik Informatika ",80,550);
g.drawString ( " Universitas : Universitas Indraprasta PGRI ",80,580);
// ini gambar bintang pertama
int xvalues [] = { 180,80,320,40,280 } ;
int yvalues [] = {60,330,180,180,330 };
g.setColor ( Color.red ) ;
g.fillPolygon ( xvalues,yvalues,xvalues.length );
//ini buat gambar bintang kedua
int xvalues2 [] = { 480,380,620,340,580 } ;
int yvalues2 [] = {60,330,180,180,330 };
g.setColor ( Color.blue ) ;
g.fillPolygon ( xvalues2,yvalues2,xvalues2.length );
//ini buat gambar bintang ketiga
int xvalues3 [] = { 780,680,920,640,880 } ;
int yvalues3 [] = {60,330,180,180,330 };
g.setColor ( Color.green ) ;
g.fillPolygon ( xvalues3,yvalues3,xvalues3.length );
}
}
Npm : 201243501228
Nama : Syahroni
Kelas : R7H
Mata Kuliah : Komputer Grafik
Dosen : Nahot Frastian , M.Kom
Program Studi : Teknik Informatika
Universitas : Universitas Indraprasta Pgri
Program Komputer Grafik :
- Bintang
Input :
import javax.swing.* ;
import java.applet.Applet ;
import java.awt.Graphics ;
import java.awt.Color ;
public class bintang extends java.applet.Applet {
public void paint ( Graphics g ) {
// -200
//ini buat String tulisan kata
g.drawString ( " Komputer Grafik : Polygon Bintang ",80,370);
g.drawString ( " Nama : Syahroni ",80,400);
g.drawString ( " Npm : 2012 4350 1228 ",80,430);
g.drawString ( " Kelas : R7H ",80,460);
g.drawString ( " Mata Kuliah : Komputer Grafik ",80,490);
g.drawString ( " Dosen : Nahot Frastian ,M.kom ",80,520);
g.drawString ( " Program Studi : Teknik Informatika ",80,550);
g.drawString ( " Universitas : Universitas Indraprasta PGRI ",80,580);
// ini gambar bintang pertama
int xvalues [] = { 180,80,320,40,280 } ;
int yvalues [] = {60,330,180,180,330 };
g.setColor ( Color.red ) ;
g.fillPolygon ( xvalues,yvalues,xvalues.length );
//ini buat gambar bintang kedua
int xvalues2 [] = { 480,380,620,340,580 } ;
int yvalues2 [] = {60,330,180,180,330 };
g.setColor ( Color.blue ) ;
g.fillPolygon ( xvalues2,yvalues2,xvalues2.length );
//ini buat gambar bintang ketiga
int xvalues3 [] = { 780,680,920,640,880 } ;
int yvalues3 [] = {60,330,180,180,330 };
g.setColor ( Color.green ) ;
g.fillPolygon ( xvalues3,yvalues3,xvalues3.length );
}
}
Material ini digunakan untuk kelas teknologi pengenalan pemrograman dengan bahasa pengantar Python http://oo.or.id/py
Dipublikasikan dengan lisensi Atribusi-Berbagi Serupa Creative Commons (CC BY-SA) oleh oon@oo.or.id
Hill Cipher ditemukan oleh Lester S. Hill pada tahun 1929, dan seperti Digraphic Ciphers lainnya, ia bertindak berdasarkan kelompok huruf. Berbeda dengan yang lain meski bisa diperpanjang untuk mengerjakan blok huruf berukuran berbeda. Jadi, secara teknis ini adalah cipher substitusi poligrafik, karena dapat bekerja pada digraf, trigraf (blok 3 huruf) atau secara teoritis setiap blok berukuran.
Hill Cipher menggunakan perhitungan matematika yang disebut Aljabar linier, dan khususnya mengharuskan pengguna untuk memiliki pemahaman dasar tentang matriks. Ini juga memanfaatkan Modulo Arithmetic (seperti the Affine Cipher). Karena itu, hill cipher memiliki sifat matematika yang jauh lebih penting daripada beberapa yang lain. Namun, sifat inilah yang memungkinkannya bertindak (relatif) dengan mudah pada blok huruf yang lebih besar.
CRUD pada Android Studio menggunakan MySQLLusiana Diyan
MySQL adalah sebuah perangkat lunak sistem manajemen basis data SQL atau DBMS yang multialur, multipengguna, dengan sekitar 6 juta instalasi di seluruh dunia.
SE - Chapter 8 Strategi Pengujian Perangkat LunakRiza Nurman
Strategi Pengujian Perangkat Lunak
PENDEKATAN STRATEGI PENGUJIAN PERANGKAT LUNAK
PENGUJIAN UNIT
PENGUJIAN INTEGRASI
PENGUJIAN VALIDASI
PENGUJIAN SISTEM
DEBUGGING
Tugas Enterprise Resource Planning, semester 7 (2017/2018), STMIK Nusa Mandiri Jakarta. Rancangan UML Aplikasi Rental Mobil: Use Case Diagram, Activity Diagram, Sequence Diagram, dan Class Diagram. Silahkan download untuk melihat lebih jelas. Aplikasi pembuatan UML menggunakan Enterprise Architect.
Material ini digunakan untuk kelas teknologi pengenalan pemrograman dengan bahasa pengantar Python http://oo.or.id/py
Dipublikasikan dengan lisensi Atribusi-Berbagi Serupa Creative Commons (CC BY-SA) oleh oon@oo.or.id
Hill Cipher ditemukan oleh Lester S. Hill pada tahun 1929, dan seperti Digraphic Ciphers lainnya, ia bertindak berdasarkan kelompok huruf. Berbeda dengan yang lain meski bisa diperpanjang untuk mengerjakan blok huruf berukuran berbeda. Jadi, secara teknis ini adalah cipher substitusi poligrafik, karena dapat bekerja pada digraf, trigraf (blok 3 huruf) atau secara teoritis setiap blok berukuran.
Hill Cipher menggunakan perhitungan matematika yang disebut Aljabar linier, dan khususnya mengharuskan pengguna untuk memiliki pemahaman dasar tentang matriks. Ini juga memanfaatkan Modulo Arithmetic (seperti the Affine Cipher). Karena itu, hill cipher memiliki sifat matematika yang jauh lebih penting daripada beberapa yang lain. Namun, sifat inilah yang memungkinkannya bertindak (relatif) dengan mudah pada blok huruf yang lebih besar.
CRUD pada Android Studio menggunakan MySQLLusiana Diyan
MySQL adalah sebuah perangkat lunak sistem manajemen basis data SQL atau DBMS yang multialur, multipengguna, dengan sekitar 6 juta instalasi di seluruh dunia.
SE - Chapter 8 Strategi Pengujian Perangkat LunakRiza Nurman
Strategi Pengujian Perangkat Lunak
PENDEKATAN STRATEGI PENGUJIAN PERANGKAT LUNAK
PENGUJIAN UNIT
PENGUJIAN INTEGRASI
PENGUJIAN VALIDASI
PENGUJIAN SISTEM
DEBUGGING
Tugas Enterprise Resource Planning, semester 7 (2017/2018), STMIK Nusa Mandiri Jakarta. Rancangan UML Aplikasi Rental Mobil: Use Case Diagram, Activity Diagram, Sequence Diagram, dan Class Diagram. Silahkan download untuk melihat lebih jelas. Aplikasi pembuatan UML menggunakan Enterprise Architect.
Why we are submitting this talk? Because Go is cool and we would like to hear more about this language ;-). In this talk we would like to tell you about our experience with development of microservices with Go. Go enables devs to create readable, fast and concise code, this - beyond any doubt is important. Apart from this we would like to leverage our test driven habbits to create bulletproof software. We will also explore other aspects important for adoption of a new language.
InterConnect: Server Side Swift for Java DevelopersChris Bailey
The range of languages and frameworks that are available for building server applications has exploded over the last few years, with the most recent of these being the Swift programming language, which IBM has been backing along with the Kitura application framework. But does this mean that Swift is the future and you should stop developing Java server applications? This session will give you an introduction to where and when you might use Kitura, and take you through the experiences of a long-time Java EE developer building their first Angular.js based Kitura application, and how that compares to building the same application with IBM WebSphere Liberty.
Conférence des Geeks Anonymes sur " le langage Go ", par Thomas Hayen le 23 septembre 2020.
Cette conférence est disponible en vidéo sur Youtube : https://youtu.be/AlGGneVGTJk
This guideline aims to provide clear instructions for submitting your GitHub repository as part of the BFAA (Belajar Fundamental Aplikasi Android) course on Dicoding. Following these guidelines will ensure that your submission is well-organized, easily navigable, and meets the evaluation criteria.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
2. Tips Trik Seputar Instalasi
- Pastikan menggunakan versi yang sama dengan yang ada di modul.
- Jika sudah pernah menginstall Java sebelumnya, install dulu versi yang lama.
- Invalidate cache/restart jika tidak bisa run EduTools.
- Disable antivirus seperti Avast.
- Jika errornya “Failed to launch checking”, coba hapus folder project dan ulangi
mengambil course.
- Pastikan koneksi lancar saat instalasi.
- Kode merah-merah? pastikan besar kecil spasi sama dengan di modul.
- Untuk pengguna 32 bit bisa mencoba install JDK lewat Azul.com
5. Hello Kotlin!
// main function
fun main() {
println("Hello Kotlin!")
}
fungsi pertama ketika
program dijalankan
untuk memberi komentar
fungsi untuk mencetak teks
ke layar/console
6. println vs print
fun main() {
println("Kotlin, ")
print("is Awesome!")
}
/*
output:
Kotlin,
is Awesome
*/
fun main() {
print("Kotlin, ")
print("is Awesome!")
}
/*
output:
Kotlin, is Awesome
*/
7. Contoh lain
fun main() {
val name = "Arif"
print("Hello my name is ")
println(name)
print(if (true) "Always true" else "Always false")
}
/*
output:
Hello my name is Arif
Always true
*/
cetak teks ke layar
untuk membuat variabel dengan tipe data string
untuk membuat
percabangan
cetak teks ke layar dan
membuat baris baru
8. Cara Menulis Variabel
var namaVariabel: TipeData = isi(value)
Contoh :
var company: String = "Dicoding"
atau bisa disingkat
var company = "Dicoding"
tipe data akan
menyesuaikan dengan
isinya
9. var vs val
Bisa diubah nilainya
(mutable)
var company = "Dicoding"
company = "Dicoding Academy"
Tidak bisa diubah nilainya
(immutable)
val company = "Dicoding"
company = "Dicoding Academy"
//Val cannot be reassigned
10. Tipe Data
Char hanya satu karakter ‘A’
String kumpulan dari banyak karakter (teks) “Kotlin”
Array menyimpan banyak objek arrayOf(“Aku”, “Kamu”, “Dia”)
Numbers angka 7
Boolean hanya memiliki 2 nilai true/false
12. Char
Operator increment & decrement
fun main() {
var vocal = 'A'
println("Vocal " + vocal++)
println("Vocal " + vocal--)
println("Vocal " + vocal)
}
/*
output:
Vocal A
Vocal B
Vocal A
*/
13. String
Memasukkan variabel ke dalam String
Contoh :
fun main() {
val text = "Kotlin"
val firstChar = text[0]
print("First character of" + text + " is " + firstChar)
}
print("First character of $text is $firstChar") string template
15. String
Membuat Raw String
Contoh :
fun main() {
val line = """
Line 1
Line 2
Line 3
Line 4
""".trimIndent()
print(line)
}
/*
output:
Line 1
Line 2
Line 3
Line 4
*/
18. Numbers
Int (32 bit) nilai angka yang umum digunakan val intNumbers = 100
Long (64 bit) nilai angka yang besar val longNumbers = 100L
Short (16 bit) nilai angka yang kecil val shortNumber: Short = 10
Byte (8 bit) nilai angka yang sangat kecil val byteNumber = 0b11010010
Double (64 bit) nilai angka pecahan val doubleNumbers = 1.3
19. Functions
tanpa nilai kembalian
fun main() {
setUser("Arif", 17)
}
fun setUser(name: String, age: Int){
println("Your name is $name, and you $age years old")
}
parameter yang dikirimkan
ke dalam fungsi
untuk membuat fungsi
20. Functions
dengan nilai kembalian
fun main() {
val user = setUser("Arif", 17)
println(user)
}
fun setUser(name: String, age: Int): String {
return "Your name is $name, and you $age years old"
}
untuk membuat nilai
kembalian
tipe data nilai yang
dikembalikan
fun setUser(name: String, age: Int) = "Your name is $name, and you $age years old"
21. If Expressions
percabangan berdasarkan kondisi
val openHours = 7
val now = 20
if (now > openHours){
println("office already open")
}
val openHours = 7
val now = 20
val office: String
if (now > openHours) {
office = "Office already open"
} else {
office = "Office is closed"
}
print(office)
val openHours = 7
val now = 7
val office: String
office = if (now > 7) {
"Office already open"
} else if (now == openHours){
"Wait a minute, office will be open"
} else {
"Office is closed"
}
print(office)
23. Safe Call Operator ?.
memanggil nullable dengan aman
val text: String? = null
text?.length
val text: String? = null
val textLength = text?.length ?: 7
Elvis Operator ?:
nilai default jika objek bernilai null
26. When Expression
Percabangan selain If Else
fun main() {
val value = 7
val stringOfValue = when (value) {
6 -> "value is 6"
7 -> "value is 7"
8 -> "value is 8"
else -> "value cannot be reached"
}
println(stringOfValue)
}
/*
output : value is 7
*/
27. When Expression
val anyType : Any = 100L
when(anyType){
is Long -> println("the value has a Long type")
is String -> println("the value has a String type")
else -> println("undefined")
}
val value = 27
val ranges = 10..50
when(value){
in ranges -> println("value is in the range")
!in ranges -> println("value is outside the range")
else -> println("value undefined")
}
val x = 11
when (x) {
10, 11 -> print("the value between 10 and 11")
11, 12 -> print("the value between 11 and 12")
}
val x = 10
when (x) {
5 + 5 -> print("the value is 10")
10 + 10 -> print("the value is 20")
}
28. Enumeration
fun main() {
val color: Color = Color.GREEN
when(color){
Color.RED -> print("Color is Red")
Color.BLUE -> print("Color is Blue")
Color.GREEN -> print("Color is Green")
}
}
enum class Color(val value: Int) {
RED(0xFF0000),
GREEN(0x00FF00),
BLUE(0x0000FF)
}
//output : Color is Green
29. While
Perulangan
fun main() {
var counter = 1
while (counter <= 5){
println("Hello, World!")
counter++
}
}
fun main() {
println("Hello World")
println("Hello World")
println("Hello World")
println("Hello World")
println("Hello World")
}
=
30. fun main() {
var counter = 1
while (counter <= 7){
println("Hello, World!")
counter++
}
}
cek dulu
baru jalankan
While vs Do While
fun main() {
var counter = 1
do {
println("Hello, World!")
counter++
} while (counter <= 7)
}
jalankan dulu
baru cek
31. Hati - Hati dengan infinite loop
Karena kondisi tidak terpenuhi
var value = 'A'
do {
print(value)
} while (value <= 'Z')
var i = 3
while (i > 3) {
println(i)
i--
}
32. val rangeInt = 1.rangeTo(10)
=
val rangeInt = 1..10
=
val rangeInt = 1 until 10
dari bawah
ke atas
rangeTo vs downTo
val downInt = 10.downTo(1)
dari atas ke bawah
33. For Loop
Perulangan dengan counter otomatis
fun main() {
val ranges = 1..5
for (i in ranges){
println("value is $i!")
}
}
fun main() {
var counter = 1
while (counter <= 5){
println("value is $counter!")
counter++
}
}
=
34. For Each
Perulangan dengan counter otomatis
fun main() {
val ranges = 1..5
ranges.forEach{
println("value is $i!")
}
}
fun main() {
val ranges = 1..5
for (i in ranges){
println("value is $i!")
}
}
=
35. Break & Continue
Contoh program deteksi angka ganjil sampai angka 10
fun main() {
val listNumber = 1.rangeTo(50)
for (number in listNumber) {
if (number % 2 == 0) continue
if (number > 10) break
println("$number adalah bilangan ganjil")
}
}
* % adalah modulus / sisa pembagian
misal 10 % 2 == 0, 11 % 2 = 1 , 9 % 6 = 3
/*
output:
1 adalah bilangan ganjil
3 adalah bilangan ganjil
5 adalah bilangan ganjil
7 adalah bilangan ganjil
9 adalah bilangan ganjil
*/
37. OUR LIFE SHOULD BE JUST LIKE
MODULUS. DOESN’T MATTER WHAT VALUE
IS ENTERED, IT’S RESULT ALWAYS
POSITIVE. AND SO SHOULD BE OUR LIFE
IN EVERY SITUATION
- Pranay Neve
’’
’’
38. You can find me at:
● Google : Ahmad Arif Faizin
● Discord : @arifaizin
Thanks!
Any questions?