SlideShare a Scribd company logo
1 of 40
Download to read offline
Java for Android
 Development
Object-Oriented Programming Concepts
Comments
/* multiline
   comment */

// singleline comment

/** Description
 *
 * @param input
 * @return output
 */
Primitive Data Types
●   byte (8-bit signed integer between -128 and 127)
●   short (16-bit signed integer between -32,768 and 32,767)
●   int (32-bit signed integer between -2,147,483,648 and 2,147,483,647)
●   long (64-bit signed integer between -9,223,372,036,854,775,808 and
    9,223,372,036,854,775,807)
●   float (32-bit floating point number)
● double (64-bit floating point number)
● boolean (true and false)
● char (single 16-bit Unicode character)
Operators
If


if (a > 0) {
    // ...
} else if (a == 0) {
    // ...
} else {
    // ...
}
boolean a;
if (a == true) ...
if (a == false) ...
if (a) ...
if (!a) ...
switch
switch (code) {
   case 200:
      // ...
      break;
   case 404:
      // ...
      break;
   default:
      // ...
      break;
}
Loops
●   while
●   do-while
●   for
●   for-each
while
int n = 10
while (n > 0) {
    n--;
}
do
n = 10;
do {
   n--;
} while (n > 0);
for
for (int i = 0; i < 100; i++) {
   //...
}
for-each
for (Object o : objects) {
   System.out.print(o.toString());
}
Branching statements
● break
● continue
● return
Arrays
String
● Immutable
● StringBuilder

●   Никогда не
    проверяйте
    равенство строк с
    помощью == !!!
Class
●   class MyClass {...}
●   instance (object)
●   fields
●   methods
●   inner and nested classes
●   this
●   final
●   static
import
●   import java.util.List;
●   import org.apache.http.HttpEntity;
●   import org.json.JSONObject;
●   import android.content.SharedPreferences;
●   import com.inflow.model.Feed;
●   import java.io.IOException;
Access Modifiers
Inheritance
●   class MyClass extends BaseClass {...}
●   super
●   @Override
Abstract Classes and Methods
● abstract class MyClass {...}
● abstract void myMethod {...}
Interfaces
● interface
● class MyClass implements MyInterface
java.lang.Object

  ○   public String toString();

  ○   public boolean equals(Object obj);

  ○   public native int hashCode();

  ○   protected native Object clone() throws CloneNotSupportedException;

  ○   protected void finalize() throws Throwable;

  ○   public final native Class<?> getClass();

  ○   public final native void notify();

  ○   public final native void notifyAll();

  ○   public final native void wait(long timeout) throws InterruptedException;

  ○   public final void wait(long timeout, int nanos) throws InterruptedException;

  ○   public final void wait() throws InterruptedException;
equals()
●   Рефлексивность: x.equals(x) -> true при x не null;

●   Симметричность: x.equals(y) <- -> y.equals(x) при x,y не null;

●   Транзитивность: x.equals(y), y.equals(z) -> x.equals(z) при x,y,z не null;

●   Непротиворечивость (consistency) «одинаковых» вызовов;

●   x.equals(null) – всегда false (при x не null).
hashCode()
●   Метод hashCode() надо переопределять в каждом классе,
    переопределяющем метод equals().
●   Контракт метода hashCode():
        ■   Непротиворечивость (consistency), «осмысленно»
            возвращает то же число;
        ■   Равные по equals() объекты дают равные значения
            hashCode();
Nested Classes
class OuterClass {
  ...
  static class StaticNestedClass {
      ...
  }
}

MyOuterClass.MyStaticNestedClass myObject = new
   MyOuterClass.MyStaticNestedClass();
Inner classes
class OuterClass {
  ...
  static class StaticNestedClass {
      ...
  }
  class InnerClass {
      ...
  }
}

OuterClass.InnerClass innerObject = outerObject.new
  InnerClass();
Anonymous classes
button.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
       //...
    }
});
Enums
public enum Day {
  SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
  THURSDAY, FRIDAY, SATURDAY
}
Exceptions
●   try
●   catch
●   finally
●   throw
Collections
●   List
●   Set
●   Map
●   Queue
●   Stack
●   ...
Extra topics
● Reflection
● Threading
● Generics
Literature
● Cay Horstmann Core Java
● Bruce Eckel Thinking in Java
Practice
●   любая предметная область
●   наследование
●   абстрактный класс
●   интерфейс

More Related Content

What's hot

Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
Duoyi Wu
 
Native code in Android applications
Native code in Android applicationsNative code in Android applications
Native code in Android applications
Dmitry Matyukhin
 
From Runnable and synchronized To atomically() and parallel()
From Runnable and synchronized To atomically() and parallel()From Runnable and synchronized To atomically() and parallel()
From Runnable and synchronized To atomically() and parallel()
José Paumard
 
Pavel kravchenko obj c runtime
Pavel kravchenko obj c runtimePavel kravchenko obj c runtime
Pavel kravchenko obj c runtime
DneprCiklumEvents
 

What's hot (20)

Datatype in JavaScript
Datatype in JavaScriptDatatype in JavaScript
Datatype in JavaScript
 
Introduzione a .NET / Mono
Introduzione a .NET / MonoIntroduzione a .NET / Mono
Introduzione a .NET / Mono
 
Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
 
2013 11 CSharp Tutorial Struct and Class
2013 11 CSharp Tutorial Struct and Class2013 11 CSharp Tutorial Struct and Class
2013 11 CSharp Tutorial Struct and Class
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
 
Js training
Js trainingJs training
Js training
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines
 
4.trasformers filters-adapters
4.trasformers filters-adapters4.trasformers filters-adapters
4.trasformers filters-adapters
 
Let's talk about jni
Let's talk about jniLet's talk about jni
Let's talk about jni
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
Native code in Android applications
Native code in Android applicationsNative code in Android applications
Native code in Android applications
 
Groovy closures
Groovy closuresGroovy closures
Groovy closures
 
From Runnable and synchronized To atomically() and parallel()
From Runnable and synchronized To atomically() and parallel()From Runnable and synchronized To atomically() and parallel()
From Runnable and synchronized To atomically() and parallel()
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
core java
core javacore java
core java
 
Pavel kravchenko obj c runtime
Pavel kravchenko obj c runtimePavel kravchenko obj c runtime
Pavel kravchenko obj c runtime
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
 
Beyond design principles and patterns (muCon 2019 edition)
Beyond design principles and patterns (muCon 2019 edition)Beyond design principles and patterns (muCon 2019 edition)
Beyond design principles and patterns (muCon 2019 edition)
 

Similar to Android Development Course in HSE lecture #2

Csharp In Detail Part2
Csharp In Detail Part2Csharp In Detail Part2
Csharp In Detail Part2
Mohamed Krar
 
Metaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailsMetaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And Grails
zenMonkey
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 

Similar to Android Development Course in HSE lecture #2 (20)

core java
 core java core java
core java
 
Java Day-4
Java Day-4Java Day-4
Java Day-4
 
Csharp In Detail Part2
Csharp In Detail Part2Csharp In Detail Part2
Csharp In Detail Part2
 
Groovy AST Transformations
Groovy AST TransformationsGroovy AST Transformations
Groovy AST Transformations
 
Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
Core2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfCore2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdf
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
 
Semmle Codeql
Semmle Codeql Semmle Codeql
Semmle Codeql
 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing Speed
 
Metaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailsMetaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And Grails
 
CHAPTER 3 part2.pdf
CHAPTER 3 part2.pdfCHAPTER 3 part2.pdf
CHAPTER 3 part2.pdf
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
Java 5 New Feature
Java 5 New FeatureJava 5 New Feature
Java 5 New Feature
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
For Beginners - C#
For Beginners - C#For Beginners - C#
For Beginners - C#
 
Static Analysis in IDEA
Static Analysis in IDEAStatic Analysis in IDEA
Static Analysis in IDEA
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 

More from Empatika

More from Empatika (20)

Gamification 101 - Intro
Gamification 101 - IntroGamification 101 - Intro
Gamification 101 - Intro
 
Travel 101 - On Distribution
Travel 101 - On DistributionTravel 101 - On Distribution
Travel 101 - On Distribution
 
Travel Tech 101 - Introduction
Travel Tech 101 - IntroductionTravel Tech 101 - Introduction
Travel Tech 101 - Introduction
 
Subscriptions business model - FAQ
Subscriptions business model - FAQSubscriptions business model - FAQ
Subscriptions business model - FAQ
 
Theories of Innovation
Theories of InnovationTheories of Innovation
Theories of Innovation
 
Lessons learned & not learned at MSU
Lessons learned & not learned at MSULessons learned & not learned at MSU
Lessons learned & not learned at MSU
 
Disruptive Innovations
Disruptive InnovationsDisruptive Innovations
Disruptive Innovations
 
US Commercial Aviation History - 1
US Commercial Aviation History - 1US Commercial Aviation History - 1
US Commercial Aviation History - 1
 
Life in a startup
Life in a startupLife in a startup
Life in a startup
 
Machine Learning - Empatika Open
Machine Learning - Empatika OpenMachine Learning - Empatika Open
Machine Learning - Empatika Open
 
Machine learning 2 - Neural Networks
Machine learning 2 - Neural NetworksMachine learning 2 - Neural Networks
Machine learning 2 - Neural Networks
 
Machine Learning - Introduction
Machine Learning - IntroductionMachine Learning - Introduction
Machine Learning - Introduction
 
Online Travel 3.0 - Mobile Traveler (Rus)
Online Travel 3.0 - Mobile Traveler (Rus)Online Travel 3.0 - Mobile Traveler (Rus)
Online Travel 3.0 - Mobile Traveler (Rus)
 
Flight to 1000000 users - Lviv IT Arena 2016
Flight to 1000000 users - Lviv IT Arena 2016Flight to 1000000 users - Lviv IT Arena 2016
Flight to 1000000 users - Lviv IT Arena 2016
 
introduction to artificial intelligence
introduction to artificial intelligenceintroduction to artificial intelligence
introduction to artificial intelligence
 
Travel inequality - Bayram Annakov
Travel inequality - Bayram AnnakovTravel inequality - Bayram Annakov
Travel inequality - Bayram Annakov
 
App in the Air Travel Hack Moscow - Fall, 2015
App in the Air Travel Hack Moscow - Fall, 2015App in the Air Travel Hack Moscow - Fall, 2015
App in the Air Travel Hack Moscow - Fall, 2015
 
Product Management
Product ManagementProduct Management
Product Management
 
Intro to Exponentials - Part 1
Intro to Exponentials - Part 1Intro to Exponentials - Part 1
Intro to Exponentials - Part 1
 
Singularity University Executive Program - Day 1
Singularity University Executive Program - Day 1Singularity University Executive Program - Day 1
Singularity University Executive Program - Day 1
 

Recently uploaded

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Recently uploaded (20)

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
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
 
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
 
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...
 
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Ữ Â...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Android Development Course in HSE lecture #2

  • 1. Java for Android Development
  • 3. Comments /* multiline comment */ // singleline comment /** Description * * @param input * @return output */
  • 4. Primitive Data Types ● byte (8-bit signed integer between -128 and 127) ● short (16-bit signed integer between -32,768 and 32,767) ● int (32-bit signed integer between -2,147,483,648 and 2,147,483,647) ● long (64-bit signed integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807) ● float (32-bit floating point number) ● double (64-bit floating point number) ● boolean (true and false) ● char (single 16-bit Unicode character)
  • 6. If if (a > 0) { // ... } else if (a == 0) { // ... } else { // ... }
  • 7. boolean a; if (a == true) ... if (a == false) ... if (a) ... if (!a) ...
  • 8. switch switch (code) { case 200: // ... break; case 404: // ... break; default: // ... break; }
  • 9. Loops ● while ● do-while ● for ● for-each
  • 10. while int n = 10 while (n > 0) { n--; }
  • 11. do n = 10; do { n--; } while (n > 0);
  • 12. for for (int i = 0; i < 100; i++) { //... }
  • 13. for-each for (Object o : objects) { System.out.print(o.toString()); }
  • 14. Branching statements ● break ● continue ● return
  • 16. String ● Immutable ● StringBuilder ● Никогда не проверяйте равенство строк с помощью == !!!
  • 17.
  • 18. Class ● class MyClass {...} ● instance (object) ● fields ● methods ● inner and nested classes ● this ● final ● static
  • 19.
  • 20. import ● import java.util.List; ● import org.apache.http.HttpEntity; ● import org.json.JSONObject; ● import android.content.SharedPreferences; ● import com.inflow.model.Feed; ● import java.io.IOException;
  • 22. Inheritance ● class MyClass extends BaseClass {...} ● super ● @Override
  • 23.
  • 24. Abstract Classes and Methods ● abstract class MyClass {...} ● abstract void myMethod {...}
  • 25.
  • 26.
  • 27. Interfaces ● interface ● class MyClass implements MyInterface
  • 28.
  • 29. java.lang.Object ○ public String toString(); ○ public boolean equals(Object obj); ○ public native int hashCode(); ○ protected native Object clone() throws CloneNotSupportedException; ○ protected void finalize() throws Throwable; ○ public final native Class<?> getClass(); ○ public final native void notify(); ○ public final native void notifyAll(); ○ public final native void wait(long timeout) throws InterruptedException; ○ public final void wait(long timeout, int nanos) throws InterruptedException; ○ public final void wait() throws InterruptedException;
  • 30. equals() ● Рефлексивность: x.equals(x) -> true при x не null; ● Симметричность: x.equals(y) <- -> y.equals(x) при x,y не null; ● Транзитивность: x.equals(y), y.equals(z) -> x.equals(z) при x,y,z не null; ● Непротиворечивость (consistency) «одинаковых» вызовов; ● x.equals(null) – всегда false (при x не null).
  • 31. hashCode() ● Метод hashCode() надо переопределять в каждом классе, переопределяющем метод equals(). ● Контракт метода hashCode(): ■ Непротиворечивость (consistency), «осмысленно» возвращает то же число; ■ Равные по equals() объекты дают равные значения hashCode();
  • 32. Nested Classes class OuterClass { ... static class StaticNestedClass { ... } } MyOuterClass.MyStaticNestedClass myObject = new MyOuterClass.MyStaticNestedClass();
  • 33. Inner classes class OuterClass { ... static class StaticNestedClass { ... } class InnerClass { ... } } OuterClass.InnerClass innerObject = outerObject.new InnerClass();
  • 34. Anonymous classes button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //... } });
  • 35. Enums public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }
  • 36. Exceptions ● try ● catch ● finally ● throw
  • 37. Collections ● List ● Set ● Map ● Queue ● Stack ● ...
  • 38. Extra topics ● Reflection ● Threading ● Generics
  • 39. Literature ● Cay Horstmann Core Java ● Bruce Eckel Thinking in Java
  • 40. Practice ● любая предметная область ● наследование ● абстрактный класс ● интерфейс