SlideShare a Scribd company logo
1 of 23
This work is licensed under the Apache 2.0 License
COMPOSE
CAMP
by
Why Kotlin
This work is licensed under the Apache 2.0 License
Kotlin is a modern programming language that helps
developers be more productive. For example, Kotlin allows you
to be more concise and write fewer lines of code for the same
functionality compared to other programming languages. Apps
that are built with Kotlin are also less likely to crash, resulting
in a more stable and robust app for users. Essentially, with
Kotlin, you can write better Android apps in a shorter amount
of time
This work is licensed under the Apache 2.0 License
Kotlin Playground
This work is licensed under the Apache 2.0 License
A Kotlin program is required to have a main function, which is the
specific place in your code where the Kotlin compiler starts. The
main function is the entry point, or starting point, of the program.
This work is licensed under the Apache 2.0 License
Define a function
• The function needs a name, so you can
call it later.
• The function can also require
some inputs, or information that needs
to be provided when the function is
called. The function uses these inputs to
accomplish its purpose. Requiring
inputs are optional, and some functions
require no inputs.
• The function also has a body which
contains the instructions to perform the
task.
This work is licensed under the Apache 2.0 License
• The function definition starts with the
word fun.
• Then the name of the function is main.
• There are no inputs to the function, so
the parentheses are empty.
• There is one line of code in the function
body, println("Hello, world!"), which is
located between the opening and closing
curly braces of the function.
This work is licensed under the Apache 2.0 License
Variables and Data Types
• A variable, which is a container
for a single piece of data.
This work is licensed under the Apache 2.0 License
Data Types:
This work is licensed under the Apache 2.0 License
Variable declaration:
For Example:
val count: Int = 2
This work is licensed under the Apache 2.0 License
Update Variables
fun main() {
val cartTotal = 0
cartTotal = 20
println("Total:
$cartTotal")
}
fun main() {
var cartTotal = 0
cartTotal = 20
println("Total:
$cartTotal")
}
This work is licensed under the Apache 2.0 License
Coding Convention
• Variable names should be in camel case and start
with a lowercase letter.
• In a variable declaration, there should be a spacafter
a colon when you specify the data type.
• There should be a space before and after an operator
like the assignment (=), addition (+), subtraction (-),
multiplication (*), division (/) operators and more.
This work is licensed under the Apache 2.0 License
Comments
Single Line: // This is a comment.
/*
Multi Line: * This is a very long comment
that can
* take up multiple lines.
*/
This work is licensed under the Apache 2.0 License
Stargazing at State
Conditionals in Kotlin
This work is licensed under the Apache 2.0 License
If-else statement
This work is licensed under the Apache 2.0 License
when statement
This work is licensed under the Apache 2.0 License
if/else and when as expressions
Migration Meadow
This work is licensed under
the Apache 2.0 License
Nullability in Kotlin
This work is licensed under the Apache 2.0 License
What is Null?
Chadwick Boseman
This work is licensed under the Apache 2.0 License
Syntax of nullable Datatype
• Nullable types are variables that can hold null.
• Non-null types are variables that can't hold null.
This work is licensed under the Apache 2.0 License
?. Safe-call operator
The ?. safe-call operator allows safer access to nullable variables
because the Kotlin compiler stops any attempt of member access
to null references and returns null for the member accessed.
This work is licensed under the Apache 2.0 License
!! not-null assertion operator
you use the !! not-null assertion, it means that you assert that the
value of the variable isn’t null, regardless of whether it is or isn’t.
Installation Of
Android Studio

More Related Content

Similar to Compose Camp#2 - Kotlin Basics.pptx

GDSC_day_1.pptx
GDSC_day_1.pptxGDSC_day_1.pptx
GDSC_day_1.pptxGDSCICOER
 
Prior programming experience track
Prior programming experience trackPrior programming experience track
Prior programming experience trackAshwinRaj57
 
-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptxRishiGandhi19
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxtakshilkunadia
 
Compose Camp S1.pptx
Compose Camp S1.pptxCompose Camp S1.pptx
Compose Camp S1.pptxGDSCSIT
 
Android study jam iiitv kick-off sesson
Android study jam iiitv   kick-off sessonAndroid study jam iiitv   kick-off sesson
Android study jam iiitv kick-off sessonAshutoshSingh1124
 
Compose Camp: Introduction to Kotlin.pptx
Compose Camp: Introduction to Kotlin.pptxCompose Camp: Introduction to Kotlin.pptx
Compose Camp: Introduction to Kotlin.pptxAmruthasriAmaravati
 
Day3New GDSC.pptx
Day3New GDSC.pptxDay3New GDSC.pptx
Day3New GDSC.pptxGDSCICOER
 
DSC ASEB Android Study Jams 2020: New to Programming 3
DSC ASEB Android Study Jams 2020: New to Programming 3DSC ASEB Android Study Jams 2020: New to Programming 3
DSC ASEB Android Study Jams 2020: New to Programming 3Aravind V. Nair
 
Android Study Jam Prior Prog S-2
Android Study Jam Prior Prog S-2Android Study Jam Prior Prog S-2
Android Study Jam Prior Prog S-2DSCIGDTUW
 
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdfAndroid Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdfShivamShrey1
 
Compose Camp Day 1.pdf
Compose Camp Day 1.pdfCompose Camp Day 1.pdf
Compose Camp Day 1.pdfShivamShrey1
 

Similar to Compose Camp#2 - Kotlin Basics.pptx (20)

GDSC_day_1.pptx
GDSC_day_1.pptxGDSC_day_1.pptx
GDSC_day_1.pptx
 
Compose Camp Day 2.pptx
Compose Camp Day 2.pptxCompose Camp Day 2.pptx
Compose Camp Day 2.pptx
 
Prior programming experience track
Prior programming experience trackPrior programming experience track
Prior programming experience track
 
Compose #1.pptx
Compose #1.pptxCompose #1.pptx
Compose #1.pptx
 
day1.docx
day1.docxday1.docx
day1.docx
 
-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx
 
-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx
 
Compose Camp Session 1.pdf
Compose Camp Session 1.pdfCompose Camp Session 1.pdf
Compose Camp Session 1.pdf
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptx
 
Compose Camp S1.pptx
Compose Camp S1.pptxCompose Camp S1.pptx
Compose Camp S1.pptx
 
Compose Camp 2.pdf
Compose Camp 2.pdfCompose Camp 2.pdf
Compose Camp 2.pdf
 
Compose Camp.pdf
Compose Camp.pdfCompose Camp.pdf
Compose Camp.pdf
 
Android Study Jams - Session 3
Android Study Jams - Session 3Android Study Jams - Session 3
Android Study Jams - Session 3
 
Android study jam iiitv kick-off sesson
Android study jam iiitv   kick-off sessonAndroid study jam iiitv   kick-off sesson
Android study jam iiitv kick-off sesson
 
Compose Camp: Introduction to Kotlin.pptx
Compose Camp: Introduction to Kotlin.pptxCompose Camp: Introduction to Kotlin.pptx
Compose Camp: Introduction to Kotlin.pptx
 
Day3New GDSC.pptx
Day3New GDSC.pptxDay3New GDSC.pptx
Day3New GDSC.pptx
 
DSC ASEB Android Study Jams 2020: New to Programming 3
DSC ASEB Android Study Jams 2020: New to Programming 3DSC ASEB Android Study Jams 2020: New to Programming 3
DSC ASEB Android Study Jams 2020: New to Programming 3
 
Android Study Jam Prior Prog S-2
Android Study Jam Prior Prog S-2Android Study Jam Prior Prog S-2
Android Study Jam Prior Prog S-2
 
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdfAndroid Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
Android Development | Compose Camp Day 1 | GDSC SEC Sasaram.pdf
 
Compose Camp Day 1.pdf
Compose Camp Day 1.pdfCompose Camp Day 1.pdf
Compose Camp Day 1.pdf
 

Recently uploaded

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Recently uploaded (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

Compose Camp#2 - Kotlin Basics.pptx

  • 1. This work is licensed under the Apache 2.0 License COMPOSE CAMP by
  • 3. This work is licensed under the Apache 2.0 License Kotlin is a modern programming language that helps developers be more productive. For example, Kotlin allows you to be more concise and write fewer lines of code for the same functionality compared to other programming languages. Apps that are built with Kotlin are also less likely to crash, resulting in a more stable and robust app for users. Essentially, with Kotlin, you can write better Android apps in a shorter amount of time
  • 4. This work is licensed under the Apache 2.0 License Kotlin Playground
  • 5. This work is licensed under the Apache 2.0 License A Kotlin program is required to have a main function, which is the specific place in your code where the Kotlin compiler starts. The main function is the entry point, or starting point, of the program.
  • 6. This work is licensed under the Apache 2.0 License Define a function • The function needs a name, so you can call it later. • The function can also require some inputs, or information that needs to be provided when the function is called. The function uses these inputs to accomplish its purpose. Requiring inputs are optional, and some functions require no inputs. • The function also has a body which contains the instructions to perform the task.
  • 7. This work is licensed under the Apache 2.0 License • The function definition starts with the word fun. • Then the name of the function is main. • There are no inputs to the function, so the parentheses are empty. • There is one line of code in the function body, println("Hello, world!"), which is located between the opening and closing curly braces of the function.
  • 8. This work is licensed under the Apache 2.0 License Variables and Data Types • A variable, which is a container for a single piece of data.
  • 9. This work is licensed under the Apache 2.0 License Data Types:
  • 10. This work is licensed under the Apache 2.0 License Variable declaration: For Example: val count: Int = 2
  • 11. This work is licensed under the Apache 2.0 License Update Variables fun main() { val cartTotal = 0 cartTotal = 20 println("Total: $cartTotal") } fun main() { var cartTotal = 0 cartTotal = 20 println("Total: $cartTotal") }
  • 12. This work is licensed under the Apache 2.0 License Coding Convention • Variable names should be in camel case and start with a lowercase letter. • In a variable declaration, there should be a spacafter a colon when you specify the data type. • There should be a space before and after an operator like the assignment (=), addition (+), subtraction (-), multiplication (*), division (/) operators and more.
  • 13. This work is licensed under the Apache 2.0 License Comments Single Line: // This is a comment. /* Multi Line: * This is a very long comment that can * take up multiple lines. */
  • 14. This work is licensed under the Apache 2.0 License Stargazing at State Conditionals in Kotlin
  • 15. This work is licensed under the Apache 2.0 License If-else statement
  • 16. This work is licensed under the Apache 2.0 License when statement
  • 17. This work is licensed under the Apache 2.0 License if/else and when as expressions
  • 18. Migration Meadow This work is licensed under the Apache 2.0 License Nullability in Kotlin
  • 19. This work is licensed under the Apache 2.0 License What is Null? Chadwick Boseman
  • 20. This work is licensed under the Apache 2.0 License Syntax of nullable Datatype • Nullable types are variables that can hold null. • Non-null types are variables that can't hold null.
  • 21. This work is licensed under the Apache 2.0 License ?. Safe-call operator The ?. safe-call operator allows safer access to nullable variables because the Kotlin compiler stops any attempt of member access to null references and returns null for the member accessed.
  • 22. This work is licensed under the Apache 2.0 License !! not-null assertion operator you use the !! not-null assertion, it means that you assert that the value of the variable isn’t null, regardless of whether it is or isn’t.