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 Java Basic Training: Hello World

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 Java Basic Training: Hello World (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-First Level
Hello Java-First LevelHello Java-First Level
Hello Java-First Level
 
Hello java
Hello java  Hello java
Hello java
 
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

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Java Basic Training: Hello World

  • 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