SlideShare a Scribd company logo
1 of 29
JAVA BASIC TRAINING
   I. The Language Essentials
HELLO WORLD



HelloWorld.java with default package

HelloWorld.java with named package


                             > javac HelloWorld.java
                             > java HelloWorld
PREPARATION
DEVELOPMENT SETUP

Editor

   Choose anyone you prefer
   But do not rush to IDE
   Make sure you’ve killed “tab”

JDK
   JDK not JRE

   6 not 7
Terminal Emulator

   Unix, Linux, Mac, but sorry M$
NAMING CONVENTION

Package
   com.ericsson.ma.javatraining
Class/Interface
   HelloWorld
Method
   helloWorld();
Variable
   String helloWorld = “Hello World”;
Constant
   HELLO_WORLD
http://java.about.com/od/javasyntax/a/nameconventions.htm
CODING STYLE

Similar with C++

Space instead of tab

Always make block with {}

Already defined for EMA development (Eclipse):

  Get it here: /proj/EMA/env/formatter.xml

  Or install the all-in-one shot
VARIABLES
VARIABLES


Instance Variables

Class Variables

Local Variables

Parameters
VARIABLES
Primitive Types
    byte (0)
    short (0)
    int (0)
    long (0L)
    float (0.0f)
    double (0.0d)
    boolean (false)
    char (‘u0000’)
Object
Array
    is an object
    must be initialized
    primitive/object
Value or References
EXERCISES



Try some illegal field names

Test default values
OPERATORS
OPERATORS



Mostly the Same as C++

equals and ==

instanceof
EXERCISES



equals and ==

instanceof
CONTROL FLOW
 STATEMENTS
CONTROL FLOW
          STATEMENTS


Enhanced for statement

Never use labeled break/continue

Avoid continue and break

Always use {} to clarify blocks
EXERCISES


Enhanced for statement

Write a small program to give number of days of a
specified month

  Read from standard input

  Input like “1”, “2”, “3”, “quit”; if “quit”, terminate
PACKAGE
PACKAGE

Naming Conventions
   java and javax are reserved by Java language itself
   domain name + product name
Importing Package
   import com.ericsson.ma.javatraining.HelloWorld;
   import static com.ericsson.ma.javatraining.HelloWorld.say;
   import com.ericsson.ma.javatraining.*;
Managing Source and Class Files
   Not required to rely on file system to manage source and class files
   As a universal convention, please rely on file system
EXERCISES


Refactor three classes into three different packages

  com.ericsson.ma.javatraining.Server => c.e.m.j.s

  com.ericsson.ma.javatraining.Utilities => c.e.m.j.u

  com.ericsson.ma.javatraining.Client => c.e.m.j.c
CLASS AND OBJECT
CLASS AND OBJECT

Class

  Constructor/”Destructor”

  Class Hierarchy

  Modifier

  Method and Field

Object

  Instance of Class

  Garbage Collector
CLASS AND OBJECT

                 Modifier      Class   Package   Subclass   World

                   public      Y        Y          Y        Y


Access Control   protected     Y        Y          Y        N


                 no modifier    Y        Y          N        N


                  private      Y        N          N        N
CLASS AND OBJECT


Class Members

 aka, static methods/fields

 Thread-safety

Instance Members
CLASS AND OBJECT


Initializing Fields

  Instance Fields

  Class Fields

  Static Block
EXERCISES

Write a few classes to represent Resource, Tester, Designer
      Common fields like id, gender, name, unit
      Test can test while designer can design, so the behaviors of working
      are different
The following code creates one array and one string object. How many
references to those objects exist after the code executes? Is either
object eligible for garbage collection?
...
String[] students = new String[10];
String studentName = "Peter Parker";
students[0] = studentName;
studentName = null;
...
ANNOTATION
ANNOTATION

Information for the Compiler

  Used by compiler to detect errors and suppress warnings
Compiler-time and Deployment-time Processing

  Software tools can process annotation to generate XML,
  files, and so on
Runtime Processing

  Available to be examined at runtime
EXERCISES




Try @Override in previous test/designer exercise

Try @SuppressWarnings
HOMEWORK

Finish all sections of http://t.cn/Ste59J

Strongly recommend http://t.cn/SteofW

Write an address book program

  Store name, address, phone number

  Possbile to search by phone number, either
  complete or partial

More Related Content

What's hot

Exception handling
Exception handlingException handling
Exception handlingRavi Sharda
 
Java căn bản - Chapter8
Java căn bản - Chapter8Java căn bản - Chapter8
Java căn bản - Chapter8Vince Vo
 
Flow or Type - how to React to that?
Flow or Type - how to React to that?Flow or Type - how to React to that?
Flow or Type - how to React to that?Krešimir Antolić
 
Perl exceptions lightning talk
Perl exceptions lightning talkPerl exceptions lightning talk
Perl exceptions lightning talkPeter Edwards
 
Exceptional Handling in Java
Exceptional Handling in JavaExceptional Handling in Java
Exceptional Handling in JavaQaziUmarF786
 
C# 6.0 - DotNetNotts
C# 6.0 - DotNetNottsC# 6.0 - DotNetNotts
C# 6.0 - DotNetNottscitizenmatt
 
Java - Exception Handling Concepts
Java - Exception Handling ConceptsJava - Exception Handling Concepts
Java - Exception Handling ConceptsVicter Paul
 
10 Things I Hate About Scala
10 Things I Hate About Scala10 Things I Hate About Scala
10 Things I Hate About ScalaMeir Maor
 
Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)mircodotta
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming LanguageRaghavan Mohan
 
Templates and Exception Handling in C++
Templates and Exception Handling in C++Templates and Exception Handling in C++
Templates and Exception Handling in C++Nimrita Koul
 

What's hot (18)

Exception handling
Exception handlingException handling
Exception handling
 
Learn Java Part 2
Learn Java Part 2Learn Java Part 2
Learn Java Part 2
 
Naming Conventions
Naming ConventionsNaming Conventions
Naming Conventions
 
Java căn bản - Chapter8
Java căn bản - Chapter8Java căn bản - Chapter8
Java căn bản - Chapter8
 
Flow or Type - how to React to that?
Flow or Type - how to React to that?Flow or Type - how to React to that?
Flow or Type - how to React to that?
 
Perl exceptions lightning talk
Perl exceptions lightning talkPerl exceptions lightning talk
Perl exceptions lightning talk
 
$Cash
$Cash$Cash
$Cash
 
Exceptional Handling in Java
Exceptional Handling in JavaExceptional Handling in Java
Exceptional Handling in Java
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 
Scala’s implicits
Scala’s implicitsScala’s implicits
Scala’s implicits
 
C# 6.0 - DotNetNotts
C# 6.0 - DotNetNottsC# 6.0 - DotNetNotts
C# 6.0 - DotNetNotts
 
Exception handling
Exception handling Exception handling
Exception handling
 
Java - Exception Handling Concepts
Java - Exception Handling ConceptsJava - Exception Handling Concepts
Java - Exception Handling Concepts
 
10 Things I Hate About Scala
10 Things I Hate About Scala10 Things I Hate About Scala
10 Things I Hate About Scala
 
Creating your own exception
Creating your own exceptionCreating your own exception
Creating your own exception
 
Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Templates and Exception Handling in C++
Templates and Exception Handling in C++Templates and Exception Handling in C++
Templates and Exception Handling in C++
 

Viewers also liked

5 the final_hard_part
5 the final_hard_part5 the final_hard_part
5 the final_hard_partHonnix Liang
 
iOS & Android Dev in C# & Visual Studio using Xamarin
iOS & Android Dev in C# & Visual Studio using XamariniOS & Android Dev in C# & Visual Studio using Xamarin
iOS & Android Dev in C# & Visual Studio using XamarinNish Anil
 
Infragistics: Getting Started with MVVM in WPF & Silverlight
Infragistics: Getting Started with MVVM in WPF & SilverlightInfragistics: Getting Started with MVVM in WPF & Silverlight
Infragistics: Getting Started with MVVM in WPF & SilverlightNish Anil
 
Building mvvm & single pageapps in js
Building mvvm & single pageapps in jsBuilding mvvm & single pageapps in js
Building mvvm & single pageapps in jsNish Anil
 
[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile apps[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile appsNish Anil
 
Evolve recap XHackers, Bangalore
Evolve recap XHackers, BangaloreEvolve recap XHackers, Bangalore
Evolve recap XHackers, BangaloreNish Anil
 
Omnipack E Catalog
Omnipack E CatalogOmnipack E Catalog
Omnipack E Catalogomnipack11
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsNish Anil
 
APAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.FormsAPAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.FormsNish Anil
 
2 the essentials of effective java
2 the essentials of effective java2 the essentials of effective java
2 the essentials of effective javaHonnix Liang
 
[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#Nish Anil
 
[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & Xamarin[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & XamarinNish Anil
 

Viewers also liked (14)

3 tool matters
3 tool matters3 tool matters
3 tool matters
 
4 maven junit
4 maven junit4 maven junit
4 maven junit
 
5 the final_hard_part
5 the final_hard_part5 the final_hard_part
5 the final_hard_part
 
iOS & Android Dev in C# & Visual Studio using Xamarin
iOS & Android Dev in C# & Visual Studio using XamariniOS & Android Dev in C# & Visual Studio using Xamarin
iOS & Android Dev in C# & Visual Studio using Xamarin
 
Infragistics: Getting Started with MVVM in WPF & Silverlight
Infragistics: Getting Started with MVVM in WPF & SilverlightInfragistics: Getting Started with MVVM in WPF & Silverlight
Infragistics: Getting Started with MVVM in WPF & Silverlight
 
Building mvvm & single pageapps in js
Building mvvm & single pageapps in jsBuilding mvvm & single pageapps in js
Building mvvm & single pageapps in js
 
[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile apps[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile apps
 
Evolve recap XHackers, Bangalore
Evolve recap XHackers, BangaloreEvolve recap XHackers, Bangalore
Evolve recap XHackers, Bangalore
 
Omnipack E Catalog
Omnipack E CatalogOmnipack E Catalog
Omnipack E Catalog
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
 
APAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.FormsAPAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.Forms
 
2 the essentials of effective java
2 the essentials of effective java2 the essentials of effective java
2 the essentials of effective java
 
[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#
 
[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & Xamarin[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & Xamarin
 

Similar to 1 the language essentials

Let's start with Java- Basic Concepts
Let's start with Java- Basic ConceptsLet's start with Java- Basic Concepts
Let's start with Java- Basic ConceptsAashish Jain
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)David McCarter
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldDavid McCarter
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldDavid McCarter
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocksİbrahim Kürce
 
JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)Prof. Erwin Globio
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Courseparveen837153
 
Introduction
IntroductionIntroduction
Introductionrichsoden
 
imperative programming language, java, android
imperative programming language, java, androidimperative programming language, java, android
imperative programming language, java, androidi i
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsMahika Tutorials
 
Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 

Similar to 1 the language essentials (20)

Let's start with Java- Basic Concepts
Let's start with Java- Basic ConceptsLet's start with Java- Basic Concepts
Let's start with Java- Basic Concepts
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
 
Hello java
Hello java  Hello java
Hello java
 
Hello java
Hello java   Hello java
Hello java
 
Hello Java-First Level
Hello Java-First LevelHello Java-First Level
Hello Java-First Level
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real World
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real World
 
Java & J2EE Coding Conventions
Java & J2EE Coding ConventionsJava & J2EE Coding Conventions
Java & J2EE Coding Conventions
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Java tutorial PPT
Java tutorial  PPTJava tutorial  PPT
Java tutorial PPT
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)JAVA Object Oriented Programming (OOP)
JAVA Object Oriented Programming (OOP)
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
 
Introduction
IntroductionIntroduction
Introduction
 
Core_java_ppt.ppt
Core_java_ppt.pptCore_java_ppt.ppt
Core_java_ppt.ppt
 
imperative programming language, java, android
imperative programming language, java, androidimperative programming language, java, android
imperative programming language, java, android
 
DAY_1.1.pptx
DAY_1.1.pptxDAY_1.1.pptx
DAY_1.1.pptx
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 

Recently uploaded

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
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
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 - 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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

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...
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+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...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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 - 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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

1 the language essentials

  • 1. JAVA BASIC TRAINING I. The Language Essentials
  • 2. HELLO WORLD HelloWorld.java with default package HelloWorld.java with named package > javac HelloWorld.java > java HelloWorld
  • 4. DEVELOPMENT SETUP Editor Choose anyone you prefer But do not rush to IDE Make sure you’ve killed “tab” JDK JDK not JRE 6 not 7 Terminal Emulator Unix, Linux, Mac, but sorry M$
  • 5. NAMING CONVENTION Package com.ericsson.ma.javatraining Class/Interface HelloWorld Method helloWorld(); Variable String helloWorld = “Hello World”; Constant HELLO_WORLD http://java.about.com/od/javasyntax/a/nameconventions.htm
  • 6. CODING STYLE Similar with C++ Space instead of tab Always make block with {} Already defined for EMA development (Eclipse): Get it here: /proj/EMA/env/formatter.xml Or install the all-in-one shot
  • 9. VARIABLES Primitive Types byte (0) short (0) int (0) long (0L) float (0.0f) double (0.0d) boolean (false) char (‘u0000’) Object Array is an object must be initialized primitive/object Value or References
  • 10. EXERCISES Try some illegal field names Test default values
  • 12. OPERATORS Mostly the Same as C++ equals and == instanceof
  • 15. CONTROL FLOW STATEMENTS Enhanced for statement Never use labeled break/continue Avoid continue and break Always use {} to clarify blocks
  • 16. EXERCISES Enhanced for statement Write a small program to give number of days of a specified month Read from standard input Input like “1”, “2”, “3”, “quit”; if “quit”, terminate
  • 18. PACKAGE Naming Conventions java and javax are reserved by Java language itself domain name + product name Importing Package import com.ericsson.ma.javatraining.HelloWorld; import static com.ericsson.ma.javatraining.HelloWorld.say; import com.ericsson.ma.javatraining.*; Managing Source and Class Files Not required to rely on file system to manage source and class files As a universal convention, please rely on file system
  • 19. EXERCISES Refactor three classes into three different packages com.ericsson.ma.javatraining.Server => c.e.m.j.s com.ericsson.ma.javatraining.Utilities => c.e.m.j.u com.ericsson.ma.javatraining.Client => c.e.m.j.c
  • 21. CLASS AND OBJECT Class Constructor/”Destructor” Class Hierarchy Modifier Method and Field Object Instance of Class Garbage Collector
  • 22. CLASS AND OBJECT Modifier Class Package Subclass World public Y Y Y Y Access Control protected Y Y Y N no modifier Y Y N N private Y N N N
  • 23. CLASS AND OBJECT Class Members aka, static methods/fields Thread-safety Instance Members
  • 24. CLASS AND OBJECT Initializing Fields Instance Fields Class Fields Static Block
  • 25. EXERCISES Write a few classes to represent Resource, Tester, Designer Common fields like id, gender, name, unit Test can test while designer can design, so the behaviors of working are different The following code creates one array and one string object. How many references to those objects exist after the code executes? Is either object eligible for garbage collection? ... String[] students = new String[10]; String studentName = "Peter Parker"; students[0] = studentName; studentName = null; ...
  • 27. ANNOTATION Information for the Compiler Used by compiler to detect errors and suppress warnings Compiler-time and Deployment-time Processing Software tools can process annotation to generate XML, files, and so on Runtime Processing Available to be examined at runtime
  • 28. EXERCISES Try @Override in previous test/designer exercise Try @SuppressWarnings
  • 29. HOMEWORK Finish all sections of http://t.cn/Ste59J Strongly recommend http://t.cn/SteofW Write an address book program Store name, address, phone number Possbile to search by phone number, either complete or partial

Editor's Notes

  1. \n
  2. - everything from stratch\n- default package, HelloWorld.java\n > main\n > pure OO\n- named package\n\n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. try to explain these in HelloWorld.java\n\nfield concept\n
  9. - show literals\n- show array usage\n- ArrayCopyDemo without print out for exercise\n
  10. - name like 1test\n- field default values, local variable default values\n
  11. \n
  12. write examples to show equals and ==\n\nString a = “hello”;\nString b = “hello”;\n\na.equals(b);\na == b\n\nString a = new String(“hello”);\nString b = new String(“hello”);\n\na.equals(b);\na == b\n
  13. \n
  14. \n
  15. for (int a : array) {\n}\n
  16. \n
  17. \n
  18. describe when to use static import and not overuse it\n
  19. \n
  20. \n
  21. there is no multi-inherits\n\nshape, rectangle, triangle to show class hierarchy\n
  22. \n
  23. mention thread safety here\n
  24. \n
  25. show -cp option when compiling\n
  26. \n
  27. \n
  28. \n
  29. \n