SlideShare a Scribd company logo
1 of 20
Download to read offline
ANDROID COURSE
WITH JAVA
Developed by Keroles Magdy
keroles.m.yacoub@gmail.com
2019 ©
Session topics :-
• String.
• Garbage collector.
• Type casting.
• Conditions and If Statements.
• Switch Statements.
• For Loop.
• For-Each Loop.
• While Loop.
• Break and Continue
• Arrays.
• Multidimensional Arrays.
String :-
• String, used for storing text.
• Is a collection of characters surrounded by double quotes.
• String greeting = "Hello";
• Concatenation :
• String greeting = "Hello" + “World" ;
Garbage collectors :-
• Garbage collectors, first unreferenced objects are identified and marked
as ready for garbage collection. Second marked objects are deleted.
Optionally, memory can be compacted after the garbage collector deletes
objects.
Type casting :-
• Widening casting, is done automatically when passing a smaller size
type to a larger size type.
• double m=9;
• Narrowing Casting, must be done manually by placing the type in
parentheses in front of the value.
• int myInt = (int) myDouble;
Conditions and If Statements:-
• IF contention syntax :
if (condition) {
// block of code to be executed if the condition is true
}
• EX :
int x = 20; int y = 18;
if (x > y) {
System.out.println("x is greater than y");
}
Conditions and If Statements:-
• IF contention syntax :
if (condition) { // block of code to be executed if the condition is true }
else { // block of code to be executed if the condition is false }
• EX :
int x= 20; int y = 18;
if (x > y) { System.out.println("x is greater than y"); }
else { System.out.println("x is equal or smaller than y") }
Conditions and If Statements:-
• IF contention syntax :
if (condition) { // block of code to be executed if the condition is true }
else if (condition) {// block of code to be executed if the condition is true}
else { // block of code to be executed if the condition is false }
• EX :
int x= 20; int y = 18;
if (x > y) { System.out.println("x is greater than y"); }
else if (x > y) { System.out.println("x is smaller than y"); }
else { System.out.println("x is equal to y") }
Conditions and If Statements:-
• Short Hand If...Else contention syntax :
variable = (condition) ? expressionTrue : expressionFalse;
• EX :
int time = 20;
String result = (time < 18) ? "Good day." : "Good evening.";
System.out.println(result);
Switch Statements :-
• Switch statement, select one of many code blocks to be executed.
• Syntax :
• switch(2) {
case 4:
code block
break;
case 2:
code block
break;
default:
code block
}
Switch Statements :-
• int day = 2;
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
default:
System.out.println("Friday");
}
Break
For Loop:-
• Syntax :
for (statement 1; statement 2; statement 3) {
// code block to be executed
}
EX :
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
For-Each Loop:-
• Syntax :
for (type variableName : arrayName) {
// code block to be executed
}
EX :
String[] cars = {"Ahmed", "Mohamed", "Ali", "Mazda"};
for (String i : cars) {
System.out.println(i);
}
While Loop :-
• Syntax :
while (condition) {
// code block to be executed
}
EX :
int i = 0;
while (i < 5) {
System.out.println(i);
i++;
}
Do While Loop :-
• Syntax :
do {
// code block to be executed
}
while (condition);
EX :
int i = 0;
do {
System.out.println(i);
i++;
}
while (i < 5);
Break and Continue :-
• Syntax :
break;
continue;
EX :
for (int i = 0; i < 10; i++) {
if (i == 4) {
break;
}
if (i == 3) {
continue;
}
System.out.println(i);
}
Arrays :-
• String [ ] cars;
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
int[] myNum = {10, 20, 30, 40};
System.out.println(cars[0]);
for (int i = 0; i < cars.length; i++) {
System.out.println(cars[i]);
}
Multidimensional Arrays :-
• int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7} };
int x = myNumbers[1][2];
System.out.println(x); // Outputs 7
for (int i = 0; i < myNumbers.length; ++i) {
for(int j = 0; j < myNumbers[i].length; ++j) {
System.out.println(myNumbers[i][j]);
}
}
the End

More Related Content

Similar to Android course session 2 ( java basics )

Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operatorsraksharao
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and SelectionAhmed Nobi
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysDevaKumari Vijay
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#Rohit Rao
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and JavaAli MasudianPour
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor ConcurrencyAlex Miller
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingPathomchon Sriwilairit
 
Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Ahmad Bashar Eter
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...corehard_by
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerAndrey Karpov
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011Juan Gomez
 
GCC Summit 2010
GCC Summit 2010GCC Summit 2010
GCC Summit 2010regehr
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...Ahmed Ali
 

Similar to Android course session 2 ( java basics ) (20)

Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
 
Jvm memory model
Jvm memory modelJvm memory model
Jvm memory model
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and Java
 
Java introduction
Java introductionJava introduction
Java introduction
 
Core java day1
Core java day1Core java day1
Core java day1
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor Concurrency
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
 
Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
 
Ethereum A to Z
Ethereum A to ZEthereum A to Z
Ethereum A to Z
 
Memory model
Memory modelMemory model
Memory model
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011
 
GCC Summit 2010
GCC Summit 2010GCC Summit 2010
GCC Summit 2010
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
 

Recently uploaded

AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...SOFTTECHHUB
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...ScyllaDB
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfAnubhavMangla3
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?Paolo Missier
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 

Recently uploaded (20)

AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 

Android course session 2 ( java basics )

  • 1. ANDROID COURSE WITH JAVA Developed by Keroles Magdy keroles.m.yacoub@gmail.com 2019 ©
  • 2. Session topics :- • String. • Garbage collector. • Type casting. • Conditions and If Statements. • Switch Statements. • For Loop. • For-Each Loop. • While Loop. • Break and Continue • Arrays. • Multidimensional Arrays.
  • 3. String :- • String, used for storing text. • Is a collection of characters surrounded by double quotes. • String greeting = "Hello"; • Concatenation : • String greeting = "Hello" + “World" ;
  • 4. Garbage collectors :- • Garbage collectors, first unreferenced objects are identified and marked as ready for garbage collection. Second marked objects are deleted. Optionally, memory can be compacted after the garbage collector deletes objects.
  • 5. Type casting :- • Widening casting, is done automatically when passing a smaller size type to a larger size type. • double m=9; • Narrowing Casting, must be done manually by placing the type in parentheses in front of the value. • int myInt = (int) myDouble;
  • 6. Conditions and If Statements:- • IF contention syntax : if (condition) { // block of code to be executed if the condition is true } • EX : int x = 20; int y = 18; if (x > y) { System.out.println("x is greater than y"); }
  • 7. Conditions and If Statements:- • IF contention syntax : if (condition) { // block of code to be executed if the condition is true } else { // block of code to be executed if the condition is false } • EX : int x= 20; int y = 18; if (x > y) { System.out.println("x is greater than y"); } else { System.out.println("x is equal or smaller than y") }
  • 8. Conditions and If Statements:- • IF contention syntax : if (condition) { // block of code to be executed if the condition is true } else if (condition) {// block of code to be executed if the condition is true} else { // block of code to be executed if the condition is false } • EX : int x= 20; int y = 18; if (x > y) { System.out.println("x is greater than y"); } else if (x > y) { System.out.println("x is smaller than y"); } else { System.out.println("x is equal to y") }
  • 9. Conditions and If Statements:- • Short Hand If...Else contention syntax : variable = (condition) ? expressionTrue : expressionFalse; • EX : int time = 20; String result = (time < 18) ? "Good day." : "Good evening."; System.out.println(result);
  • 10. Switch Statements :- • Switch statement, select one of many code blocks to be executed. • Syntax : • switch(2) { case 4: code block break; case 2: code block break; default: code block }
  • 11. Switch Statements :- • int day = 2; switch (day) { case 1: System.out.println("Monday"); break; case 2: System.out.println("Tuesday"); break; default: System.out.println("Friday"); }
  • 12. Break
  • 13. For Loop:- • Syntax : for (statement 1; statement 2; statement 3) { // code block to be executed } EX : for (int i = 0; i < 5; i++) { System.out.println(i); }
  • 14. For-Each Loop:- • Syntax : for (type variableName : arrayName) { // code block to be executed } EX : String[] cars = {"Ahmed", "Mohamed", "Ali", "Mazda"}; for (String i : cars) { System.out.println(i); }
  • 15. While Loop :- • Syntax : while (condition) { // code block to be executed } EX : int i = 0; while (i < 5) { System.out.println(i); i++; }
  • 16. Do While Loop :- • Syntax : do { // code block to be executed } while (condition); EX : int i = 0; do { System.out.println(i); i++; } while (i < 5);
  • 17. Break and Continue :- • Syntax : break; continue; EX : for (int i = 0; i < 10; i++) { if (i == 4) { break; } if (i == 3) { continue; } System.out.println(i); }
  • 18. Arrays :- • String [ ] cars; String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; int[] myNum = {10, 20, 30, 40}; System.out.println(cars[0]); for (int i = 0; i < cars.length; i++) { System.out.println(cars[i]); }
  • 19. Multidimensional Arrays :- • int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7} }; int x = myNumbers[1][2]; System.out.println(x); // Outputs 7 for (int i = 0; i < myNumbers.length; ++i) { for(int j = 0; j < myNumbers[i].length; ++j) { System.out.println(myNumbers[i][j]); } }