SlideShare a Scribd company logo
1 of 65
About Java (SE)
 ore than Beginning



                      Jay Xu
Agenda
 Java History                         Exception
 OO                                   Primitive Type / Wrapper
      Object / Class / Interface   Tea break
      Inheritance /                Java Architecture at a
      Polymorphism                 Glance (Java 6)
      Override / Overload          New Features since JDK 5
      Access Level / Visibility       Generics
      this / super / static        Touch GC
      Inner Class
Java History I
Java History II
Java History III
Object / Class / Interface I
 What is an object / class (interface)?
    Human VS Jay
    Template VS Instance
public class Human {
    private int age; // default value?
    private String name; // default value?

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

Human jay = new Human();
jay.setName(“Jay”);
jay.setAge(28);
Object / Class / Interface II
 Why OO?
   Cohesion / encapsulation
   Direct
      Human.say(“Hello”) VS say(&Human, “hello”)
   Inheritance Unit
Inheritance / Polymorphism
 Inheritance
    Code Reusing (copy / extend)
 Polymorphism
    Dynamic Runtime Binding
        Dynamic
        Runtime
        Binding
    Java VS C++ (e.g.)
Polymorphism (Java VS                                C++)

public class Human{               class Human{
    public void say(){            public:
        System.out.println(“I         virtual void say(){
am a human”);                             cout << “I am a human”;
    }                                 }
}                                 };

public class Jay extends Human{   class Jay : public Human{
    public void say(){            public:
        System.out.println(“I         void say(){
am Jay”);                                 cout << “I am Jay”;
    }                                 }
}                                 };

Human human = new Jay();          Human* human = new Jay();
human.say(); // which say()?      human->say(); // which say()?
Overload / Override
 Overload
    Different Method Signature
       Same Method Name
       Different Parameters (?)
       Different Return Type (?)
 Override
    Same Method Signature
public class SuperOverrideOverload {

    public void overload(int number) {
        System.out.println("super int overload");
    }

    public void overload(Integer number) {
        System.out.println("super Integer overload");
    }

    public void overload(long number) {
        System.out.println("super long overload");
    }

    public void overload(Long number) {
        System.out.println("super Long overload");
    }

    public void overload(Object number) {
        System.out.println("super Object overload");
    }

    public static void main(String[] args) {
        new SuperOverrideOverload().overload(100);
    }
}
public class OverrideOverload extends SuperOverrideOverload {

    @Override
    public void overload(int number) {
        System.out.println("int overload");
    }

    @Override
    public void overload(Integer number) {
        System.out.println("Integer overload");
    }

    @Override
    public void overload(long number) {
        System.out.println("long overload");
    }

    @Override
    public void overload(Long number) {
        System.out.println("Long overload");
    }

    @Override
    public void overload(Object number) {
        System.out.println("Object overload");
    }

    public static void main(String[] args) {
        new OverrideOverload().overload(100);
    }
}
Access Level / Visibility
 public
 protected
 private
 (default)
super / this / static
 super.xxx()
 super()
 this.xxx()
 this()
 static
      public static void main(String[] args)
 Instance initialize order
      Default values
Inner Class
 Types
    Inner class
    Static inner class
    Anonymous (parameter) inner class
 this
 Access level
(Static) Inner Class
public class Outer {
    private int id;
    public class Inner {
        private int id;
        private int getID() {
            return this.id; // which id?
        }
    }
}
new Outer().new Inner();

public class Outer {
    public static class Inner {}
}
new Outer.Inner();
Anonymous (Parameter)
Inner Class
Runnable runnable = new Runnable() {
    public void run() {
        ...
    }
};

public void doRun(Runnable runnable) {...}
doRun(new Runnable() {
    public void run() {
        ...
    }
});
Primitive Type / Wrapper
 byte - Byte         char - Character
     8 bit signed        16 bit unsigned
 short - Short       float - Float
     16 bit signed       32 bit signed
 int - Integer       double - Double
     32 bit signed       64 bit signed
 long - Long         boolean - Boolean
     64 bit signed
Exception
 Why Exception?
    Error Code VS Exception
    What’s in an Exception?
        Message (String)
        Cause (Throwable)
        Stacktrace[]
             exception location info. (log4j)
    try / catch / finally
Tea Break
Java 6 Architecture
 http://java.sun.com/javase/6/docs/
New Features Since Java 5
 Varargs

 Enhanced for Loop
 Annotation
 Auto Boxing / Unboxing
 Enum
    Constants VS Enum
    java.lang.Enum
 Static Import
Varargs
public int sum(int... numbers) {
    int sum = 0;
    for(int number:numbers) {
        sum += number;
    }

    return sum;
}
Enhanced for Loop
Enhanced for Loop
List <String> strings = ...;
Enhanced for Loop
List <String> strings = ...;
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}

Iterator<String> iter = string.iterator();
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}

Iterator<String> iter = string.iterator();
while(iter.hasNext()) {
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}

Iterator<String> iter = string.iterator();
while(iter.hasNext()) {
    String string = iter.next();
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}

Iterator<String> iter = string.iterator();
while(iter.hasNext()) {
    String string = iter.next();
    ...
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}

Iterator<String> iter = string.iterator();
while(iter.hasNext()) {
    String string = iter.next();
    ...
}
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}

Iterator<String> iter = string.iterator();
while(iter.hasNext()) {
    String string = iter.next();
    ...
}
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}

Iterator<String> iter = string.iterator();
while(iter.hasNext()) {
    String string = iter.next();
    ...
}

for(String string:strings) {
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}

Iterator<String> iter = string.iterator();
while(iter.hasNext()) {
    String string = iter.next();
    ...
}

for(String string:strings) {
    ...
Enhanced for Loop
List <String> strings = ...;

for (int i = 0;i<strings.length();i++) {
    String string = strings.get(i);
    ...
}

Iterator<String> iter = string.iterator();
while(iter.hasNext()) {
    String string = iter.next();
    ...
}

for(String string:strings) {
    ...
}
Annotation
public class Annotation {
    @Override
    public String toString() {...}
}
Auto Boxing / Unboxing
List<Integer> numbers = ...;

for(int i = 0;i<100;i++) {
    numbers.add(i);
}

int sum = 0;
for(int number:numbers) {
    sum += number;
}
Enum
public enum Gender {           public abstract
    MALE() {               String toString();
        public String      }
toString() {
             return “ ”;   switch(gender) {
                               case MALE: ...
        }
                               case FEMALE: ...
    }, FEMALE() {
                           }
        public String
toString() {
                           if(gender == MALE) {...}
             return “ ”;
         }                 gender.name();
    };
                           Enum.valueOf(Gender.clas
                           s, “MALE”);
Static Import

public double calculate (double a, double b, double c){
    return Math.sqrt(a * a + b * b) + 2 * Math.PI *
Math.sin(c);
}



import static java.lang.Math.*;
public double calculate (double a, double b, double c){
    return sqrt(a * a + b * b) + 2 * PI * sin(c);
}
Generics
 Type Template
    String[] VS List (prev.)
 Erasing (during compilation)
 How to Use?
    String[] VS List<String> (now)
    ?, extends
 How to Define?
Generics I
List strings = ...;
strings.add(“hello”);
strings.add(Boolean.TRUE); // error?

for(int i = 0;i<strings.length();i++) {
    String string = (String)strings.get(i);
    ...
}



List<String> strings = ...;
Generics II
Generics II
public class List<T> {
Generics II
public class List<T> {
    public void add(T t) {...}
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}

public static <T extends Enum<T>> T valueOf(Class<T> type,
String string) {...}
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}

public static <T extends Enum<T>> T valueOf(Class<T> type,
String string) {...}
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}

public static <T extends Enum<T>> T valueOf(Class<T> type,
String string) {...}

List<String> strings = ...;
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}

public static <T extends Enum<T>> T valueOf(Class<T> type,
String string) {...}

List<String> strings = ...;
public addObjects(List<Object> list) {...}
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}

public static <T extends Enum<T>> T valueOf(Class<T> type,
String string) {...}

List<String> strings = ...;
public addObjects(List<Object> list) {...}
addObjects(strings); // error?
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}

public static <T extends Enum<T>> T valueOf(Class<T> type,
String string) {...}

List<String> strings = ...;
public addObjects(List<Object> list) {...}
addObjects(strings); // error?
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}

public static <T extends Enum<T>> T valueOf(Class<T> type,
String string) {...}

List<String> strings = ...;
public addObjects(List<Object> list) {...}
addObjects(strings); // error?

public addObjects(List<? extends Object> list) {...}
Generics II
public class List<T> {
    public void add(T t) {...}
    public T get(int index) {...}
    ....
}

public static <T extends Enum<T>> T valueOf(Class<T> type,
String string) {...}

List<String> strings = ...;
public addObjects(List<Object> list) {...}
addObjects(strings); // error?

public addObjects(List<? extends Object> list) {...}
addObjects(strings); // error?
Touch GC
 What is Garbage?             “Generation”
    Isolated Objects       Memory Leak (in Java)?
 How to Collect?              Why?
    Heap VS Stack             How to Avoid?

    Reference Count
    Compress and Collect
    Copy and Collect
Revision
 Java History                         Inner Class
 OO                                   Exception
      Object / Class / Interface      Primitive Type / Wrapper
      Inheritance /                Java Architecture at a
      Polymorphism                 Glance (Java 6)
      Override / Overload          New Features since JDK 5
      Access Level / Visibility       Generics
      this / super / static        Touch GC
Q   A

More Related Content

What's hot

Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecLoïc Descotte
 
Swift for TensorFlow - CoreML Personalization
Swift for TensorFlow - CoreML PersonalizationSwift for TensorFlow - CoreML Personalization
Swift for TensorFlow - CoreML PersonalizationJacopo Mangiavacchi
 
Real world gobbledygook
Real world gobbledygookReal world gobbledygook
Real world gobbledygookPawel Szulc
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlinintelliyole
 
Functional Programming & Event Sourcing - a pair made in heaven
Functional Programming & Event Sourcing - a pair made in heavenFunctional Programming & Event Sourcing - a pair made in heaven
Functional Programming & Event Sourcing - a pair made in heavenPawel Szulc
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner codeMite Mitreski
 
Code generation for alternative languages
Code generation for alternative languagesCode generation for alternative languages
Code generation for alternative languagesRafael Winterhalter
 
Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)intelliyole
 
Python 표준 라이브러리
Python 표준 라이브러리Python 표준 라이브러리
Python 표준 라이브러리용 최
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うbpstudy
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)Alok Kumar
 
Implementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingImplementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingVincent Pradeilles
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and JavaAli MasudianPour
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Introthnetos
 
Predictably
PredictablyPredictably
Predictablyztellman
 

What's hot (20)

ddd+scala
ddd+scaladdd+scala
ddd+scala
 
final year project center in Coimbatore
final year project center in Coimbatorefinal year project center in Coimbatore
final year project center in Coimbatore
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Google guava
Google guavaGoogle guava
Google guava
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
 
Swift for TensorFlow - CoreML Personalization
Swift for TensorFlow - CoreML PersonalizationSwift for TensorFlow - CoreML Personalization
Swift for TensorFlow - CoreML Personalization
 
Hammurabi
HammurabiHammurabi
Hammurabi
 
Real world gobbledygook
Real world gobbledygookReal world gobbledygook
Real world gobbledygook
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
Functional Programming & Event Sourcing - a pair made in heaven
Functional Programming & Event Sourcing - a pair made in heavenFunctional Programming & Event Sourcing - a pair made in heaven
Functional Programming & Event Sourcing - a pair made in heaven
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner code
 
Code generation for alternative languages
Code generation for alternative languagesCode generation for alternative languages
Code generation for alternative languages
 
Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)
 
Python 표준 라이브러리
Python 표준 라이브러리Python 표준 라이브러리
Python 표준 라이브러리
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使う
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
 
Implementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingImplementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional Programing
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and Java
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
Predictably
PredictablyPredictably
Predictably
 

Viewers also liked

Eclipse using tricks
Eclipse using tricksEclipse using tricks
Eclipse using tricksJay Xu
 
Sworks drupal
Sworks drupalSworks drupal
Sworks drupalSworks
 
从码农到大师—— 我看程序员的成长
从码农到大师—— 我看程序员的成长从码农到大师—— 我看程序员的成长
从码农到大师—— 我看程序员的成长Jay Xu
 
Sworks facebook
Sworks facebookSworks facebook
Sworks facebookSworks
 
Google Enterprise App Intro
Google Enterprise App IntroGoogle Enterprise App Intro
Google Enterprise App IntroJay Xu
 
Involvement of thea
Involvement of theaInvolvement of thea
Involvement of theaguestb139e76
 

Viewers also liked (7)

Compressor
CompressorCompressor
Compressor
 
Eclipse using tricks
Eclipse using tricksEclipse using tricks
Eclipse using tricks
 
Sworks drupal
Sworks drupalSworks drupal
Sworks drupal
 
从码农到大师—— 我看程序员的成长
从码农到大师—— 我看程序员的成长从码农到大师—— 我看程序员的成长
从码农到大师—— 我看程序员的成长
 
Sworks facebook
Sworks facebookSworks facebook
Sworks facebook
 
Google Enterprise App Intro
Google Enterprise App IntroGoogle Enterprise App Intro
Google Enterprise App Intro
 
Involvement of thea
Involvement of theaInvolvement of thea
Involvement of thea
 

Similar to About java

CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
Java 5 New Feature
Java 5 New FeatureJava 5 New Feature
Java 5 New Featurexcoda
 
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Ayes Chinmay
 
Having a problem figuring out where my errors are- The code is not run.pdf
Having a problem figuring out where my errors are- The code is not run.pdfHaving a problem figuring out where my errors are- The code is not run.pdf
Having a problem figuring out where my errors are- The code is not run.pdfNicholasflqStewartl
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfakshpatil4
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfShashikantSathe3
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlinThijs Suijten
 
Scala - fra newbie til ninja på en time
Scala - fra newbie til ninja på en timeScala - fra newbie til ninja på en time
Scala - fra newbie til ninja på en timekarianneberg
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版Yutaka Kato
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agentsRafael Winterhalter
 
Multimethods
MultimethodsMultimethods
MultimethodsAman King
 
Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)ThomasHorta
 

Similar to About java (20)

CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
Java 5 New Feature
Java 5 New FeatureJava 5 New Feature
Java 5 New Feature
 
Java.lang.object
Java.lang.objectJava.lang.object
Java.lang.object
 
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
 
Having a problem figuring out where my errors are- The code is not run.pdf
Having a problem figuring out where my errors are- The code is not run.pdfHaving a problem figuring out where my errors are- The code is not run.pdf
Having a problem figuring out where my errors are- The code is not run.pdf
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdf
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
 
Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlin
 
Scala - fra newbie til ninja på en time
Scala - fra newbie til ninja på en timeScala - fra newbie til ninja på en time
Scala - fra newbie til ninja på en time
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版
 
Java programs
Java programsJava programs
Java programs
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agents
 
Multimethods
MultimethodsMultimethods
Multimethods
 
C# Is The Future
C# Is The FutureC# Is The Future
C# Is The Future
 
Java Cheat Sheet
Java Cheat SheetJava Cheat Sheet
Java Cheat Sheet
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)
 

Recently uploaded

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Recently uploaded (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

About java

  • 1. About Java (SE) ore than Beginning Jay Xu
  • 2. Agenda Java History Exception OO Primitive Type / Wrapper Object / Class / Interface Tea break Inheritance / Java Architecture at a Polymorphism Glance (Java 6) Override / Overload New Features since JDK 5 Access Level / Visibility Generics this / super / static Touch GC Inner Class
  • 6. Object / Class / Interface I What is an object / class (interface)? Human VS Jay Template VS Instance
  • 7. public class Human { private int age; // default value? private String name; // default value? public void setName(String name) { this.name = name; } public void setAge(int age) { this.age = age; } } Human jay = new Human(); jay.setName(“Jay”); jay.setAge(28);
  • 8. Object / Class / Interface II Why OO? Cohesion / encapsulation Direct Human.say(“Hello”) VS say(&Human, “hello”) Inheritance Unit
  • 9. Inheritance / Polymorphism Inheritance Code Reusing (copy / extend) Polymorphism Dynamic Runtime Binding Dynamic Runtime Binding Java VS C++ (e.g.)
  • 10. Polymorphism (Java VS C++) public class Human{ class Human{ public void say(){ public: System.out.println(“I virtual void say(){ am a human”); cout << “I am a human”; } } } }; public class Jay extends Human{ class Jay : public Human{ public void say(){ public: System.out.println(“I void say(){ am Jay”); cout << “I am Jay”; } } } }; Human human = new Jay(); Human* human = new Jay(); human.say(); // which say()? human->say(); // which say()?
  • 11. Overload / Override Overload Different Method Signature Same Method Name Different Parameters (?) Different Return Type (?) Override Same Method Signature
  • 12. public class SuperOverrideOverload { public void overload(int number) { System.out.println("super int overload"); } public void overload(Integer number) { System.out.println("super Integer overload"); } public void overload(long number) { System.out.println("super long overload"); } public void overload(Long number) { System.out.println("super Long overload"); } public void overload(Object number) { System.out.println("super Object overload"); } public static void main(String[] args) { new SuperOverrideOverload().overload(100); } }
  • 13. public class OverrideOverload extends SuperOverrideOverload { @Override public void overload(int number) { System.out.println("int overload"); } @Override public void overload(Integer number) { System.out.println("Integer overload"); } @Override public void overload(long number) { System.out.println("long overload"); } @Override public void overload(Long number) { System.out.println("Long overload"); } @Override public void overload(Object number) { System.out.println("Object overload"); } public static void main(String[] args) { new OverrideOverload().overload(100); } }
  • 14. Access Level / Visibility public protected private (default)
  • 15. super / this / static super.xxx() super() this.xxx() this() static public static void main(String[] args) Instance initialize order Default values
  • 16. Inner Class Types Inner class Static inner class Anonymous (parameter) inner class this Access level
  • 17. (Static) Inner Class public class Outer { private int id; public class Inner { private int id; private int getID() { return this.id; // which id? } } } new Outer().new Inner(); public class Outer { public static class Inner {} } new Outer.Inner();
  • 18. Anonymous (Parameter) Inner Class Runnable runnable = new Runnable() { public void run() { ... } }; public void doRun(Runnable runnable) {...} doRun(new Runnable() { public void run() { ... } });
  • 19. Primitive Type / Wrapper byte - Byte char - Character 8 bit signed 16 bit unsigned short - Short float - Float 16 bit signed 32 bit signed int - Integer double - Double 32 bit signed 64 bit signed long - Long boolean - Boolean 64 bit signed
  • 20. Exception Why Exception? Error Code VS Exception What’s in an Exception? Message (String) Cause (Throwable) Stacktrace[] exception location info. (log4j) try / catch / finally
  • 22. Java 6 Architecture http://java.sun.com/javase/6/docs/
  • 23. New Features Since Java 5 Varargs Enhanced for Loop Annotation Auto Boxing / Unboxing Enum Constants VS Enum java.lang.Enum Static Import
  • 24. Varargs public int sum(int... numbers) { int sum = 0; for(int number:numbers) { sum += number; } return sum; }
  • 26. Enhanced for Loop List <String> strings = ...;
  • 27. Enhanced for Loop List <String> strings = ...;
  • 28. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) {
  • 29. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i);
  • 30. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ...
  • 31. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... }
  • 32. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... }
  • 33. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... } Iterator<String> iter = string.iterator();
  • 34. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... } Iterator<String> iter = string.iterator(); while(iter.hasNext()) {
  • 35. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... } Iterator<String> iter = string.iterator(); while(iter.hasNext()) { String string = iter.next();
  • 36. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... } Iterator<String> iter = string.iterator(); while(iter.hasNext()) { String string = iter.next(); ...
  • 37. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... } Iterator<String> iter = string.iterator(); while(iter.hasNext()) { String string = iter.next(); ... }
  • 38. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... } Iterator<String> iter = string.iterator(); while(iter.hasNext()) { String string = iter.next(); ... }
  • 39. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... } Iterator<String> iter = string.iterator(); while(iter.hasNext()) { String string = iter.next(); ... } for(String string:strings) {
  • 40. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... } Iterator<String> iter = string.iterator(); while(iter.hasNext()) { String string = iter.next(); ... } for(String string:strings) { ...
  • 41. Enhanced for Loop List <String> strings = ...; for (int i = 0;i<strings.length();i++) { String string = strings.get(i); ... } Iterator<String> iter = string.iterator(); while(iter.hasNext()) { String string = iter.next(); ... } for(String string:strings) { ... }
  • 42. Annotation public class Annotation { @Override public String toString() {...} }
  • 43. Auto Boxing / Unboxing List<Integer> numbers = ...; for(int i = 0;i<100;i++) { numbers.add(i); } int sum = 0; for(int number:numbers) { sum += number; }
  • 44. Enum public enum Gender { public abstract MALE() { String toString(); public String } toString() { return “ ”; switch(gender) { case MALE: ... } case FEMALE: ... }, FEMALE() { } public String toString() { if(gender == MALE) {...} return “ ”; } gender.name(); }; Enum.valueOf(Gender.clas s, “MALE”);
  • 45. Static Import public double calculate (double a, double b, double c){ return Math.sqrt(a * a + b * b) + 2 * Math.PI * Math.sin(c); } import static java.lang.Math.*; public double calculate (double a, double b, double c){ return sqrt(a * a + b * b) + 2 * PI * sin(c); }
  • 46. Generics Type Template String[] VS List (prev.) Erasing (during compilation) How to Use? String[] VS List<String> (now) ?, extends How to Define?
  • 47. Generics I List strings = ...; strings.add(“hello”); strings.add(Boolean.TRUE); // error? for(int i = 0;i<strings.length();i++) { String string = (String)strings.get(i); ... } List<String> strings = ...;
  • 50. Generics II public class List<T> { public void add(T t) {...}
  • 51. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...}
  • 52. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} ....
  • 53. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... }
  • 54. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... }
  • 55. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... } public static <T extends Enum<T>> T valueOf(Class<T> type, String string) {...}
  • 56. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... } public static <T extends Enum<T>> T valueOf(Class<T> type, String string) {...}
  • 57. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... } public static <T extends Enum<T>> T valueOf(Class<T> type, String string) {...} List<String> strings = ...;
  • 58. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... } public static <T extends Enum<T>> T valueOf(Class<T> type, String string) {...} List<String> strings = ...; public addObjects(List<Object> list) {...}
  • 59. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... } public static <T extends Enum<T>> T valueOf(Class<T> type, String string) {...} List<String> strings = ...; public addObjects(List<Object> list) {...} addObjects(strings); // error?
  • 60. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... } public static <T extends Enum<T>> T valueOf(Class<T> type, String string) {...} List<String> strings = ...; public addObjects(List<Object> list) {...} addObjects(strings); // error?
  • 61. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... } public static <T extends Enum<T>> T valueOf(Class<T> type, String string) {...} List<String> strings = ...; public addObjects(List<Object> list) {...} addObjects(strings); // error? public addObjects(List<? extends Object> list) {...}
  • 62. Generics II public class List<T> { public void add(T t) {...} public T get(int index) {...} .... } public static <T extends Enum<T>> T valueOf(Class<T> type, String string) {...} List<String> strings = ...; public addObjects(List<Object> list) {...} addObjects(strings); // error? public addObjects(List<? extends Object> list) {...} addObjects(strings); // error?
  • 63. Touch GC What is Garbage? “Generation” Isolated Objects Memory Leak (in Java)? How to Collect? Why? Heap VS Stack How to Avoid? Reference Count Compress and Collect Copy and Collect
  • 64. Revision Java History Inner Class OO Exception Object / Class / Interface Primitive Type / Wrapper Inheritance / Java Architecture at a Polymorphism Glance (Java 6) Override / Overload New Features since JDK 5 Access Level / Visibility Generics this / super / static Touch GC
  • 65. Q A

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n