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

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

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