SlideShare a Scribd company logo
Java Basics
by Yuriy Voznyak, Software Engineer
eleks.com
Lecture Goal or Why Java?
● Become familiar with one more great
platform;
● Introduction to Android development;
● Understand the difference between
Java and another popular languages
such as C# or C++
● 30 Billion Devices
● ...
Why did Java invent?
1. Write Once, Run Everywhere. This old Sun slogan describes very ambitious
goal. Sun wanted to create cross-platform language;
2. Java Virtual Machine should run every application in the separate sandbox
with dedicated permission; So, applications and environment should provide
better security than with using of unmanaged code
3. Easy distribution over Internet as Java applications or Java Applets;
4. Built-in Multithreading support;
5. To replace C/C++ with a better design;
What do I need for Java?
● If I want to run Java applications on Desktop, there is a JRE (Java Runtime
Environment);
● For servers there is another JRE - Server JRE (Server Java Runtime
Environment). Contains tools for JVM monitoring and some tools required for
server applications, but does not include browser integration (the Java plug-in),
auto-update, nor an installer;
● I want to develop Java Software: need Oracle JDK (Java Development Kit).
Includes a complete JRE plus tools for developing, debugging, and monitoring
Java applications;
● I want to learn Java deeper or have some extra needs: there is open-source Java
implementation called OpenJDK.
Java Editions
Java Standard
Edition (Java SE)
lets you develop and
deploy Java applications
on desktops and servers,
as well as embedded
environments. Most
common used.
Java Enterprise
Edition (Java EE)
Extended overset of java
engine, contains
specifications for designing
and developing of Big
Enterprise Network
Applications
Java Micro Edition
(Java ME)
a subset of Java, designed
for devices with limited
hardware characteristics.
Java Embedded
Edition
Oracle`s marketing term.
Contain some binaries to
work with Raspberry Pi
or ARM devboards
Java DB
Just a implementation of
open-source database
engine
Java Card
Technology to develop
Smart Cards secure
applets. Sooo limited
and low-level
Marketing sets Specialized
Technologies Structure
Noticeable Java Feature Differences
● Syntax is a bit simpler. Really
● Packages instead of namespaces
● No default values
● Values are passed by value only. But, for reference types, value is reference.
So, you just pass copy of the reverence: is able to modify but unable to assign
another reference;
● Methods names begin from capital letter :)
● Observer patterns everywhere with anonymous classes
● Java runs not only on Windows
● Less syntax sugar
Main Method
C#
static void Main(string[] args)
… or even
static void Main()
Java
public static void main(String[] args)
Standard Output
C#
System.Console.WriteLine("Important Message");
Java
System.out.println("Important Message");
Declaring Constants
C#
const int Constant = 42;
Java
[public] static final int CONSTANT = 42;
Inheritance
C#
class Child : Parent, IDerivable
{
...
}
Java
class Child extends Parent implements Derivable {
...
}
Exceptions
1-dimensional Collections
Primitive Types
type size range default value wrapper
byte 1 From +127 to -128 0 Byte
short 2 From +32,767 to -32,768 0 Short
int 4 From +2,147,483,647 to -2,147,483,648 0 Integer
long 8 From +9,223,372,036,854,775,807 to -
9,223,372,036,854,775,808
0L Long
float 4 From 3.402,823,5 E+38 to 1.4 E-45 0.0f Float
double 8 From 1.797,693,134,862,315,7 E+308 to 4.9 E-324 0.0d Double
char 2 All Unicode characters 'u0000' Character
boolean 1 False, true false Boolean
Moar Difference
● In Java methods are virtual by default but you can make them final. (In C# they are
sealed by default, but you can make them virtual.)
● Generics are completely different between the two; Java generics are just a
compile-time "trick" (but a useful one at that). In C# and .NET generics are
maintained at execution time too, and work for value types as well as reference
types.
● Java doesn't allow the creation of user-defined value types
● Java doesn't support overloading
● Java doesn't have anything like LINQ
● Partly due to not having delegates, Java doesn't have anything quite like
anonymous methods and lambda expressions (in Java 8 does). Anonymous inner
classes usually fill these roles.
● Java doesn't have implicitly typed local variables (var directive)
Please, stop!
● Java doesn't have extension methods
● The access modifiers are somewhat different - in Java there's (currently) no direct
equivalent of an assembly, so no idea of "internal" visibility;
● Java doesn't have the equivalent of "unsafe" code
● Java has no preprocessor directives (#define, #if etc)
● Java has no equivalent of C#'s ref and out for passing parameters by reference
● Java has no equivalent of partial types
● Java has no unsigned integer types
● Java has no language support for a decimal type. However, java.math.BigDecimal
provides similar functionality
● Java has no equivalent of nullable value types
● Java doesn't have static classes (which don't have any instance constructors, and
can't be used for variables, parameters etc)
Is it all?
Of course, no.
However…
● in C# there's no equivalent to the "default" visibility in Java which takes account of
namespace
● C# interfaces cannot declare fields. In java interfaces can contain static final fields
and even implementation (sic!)
● C# doesn't have checked exceptions
● C# doesn't have anonymous inner classes
● C# doesn't have Java's inner classes at all, in fact - all nested classes in C# are like
Java's static nested classes
How to write Java application?
1.
2.
What is Jar
JAR file is a file format based on the popular ZIP file format
and is used for aggregating many files into one. A JAR file
is essentially a zip file that contains an optional META-INF
directory. A JAR file can be created by the command-line
jar tool, or by using the java.util.jar API in the Java
platform. There is no restriction on the name of a JAR file,
it can be any legal file name on a particular platform.
In many cases, JAR files are not just simple archives of
java classes files and/or resources. They are used as
building blocks for applications and extensions. The
META-INF directory, if it exists, is used to store package
and extension configuration data, including security,
versioning, extension and services.
Designing Classes Structure
explicit-representation principle: classes included to reflect natural categories;
no-duplication principle: member functions situated among class definitions to facilitate
sharing;
local-view principle: program elements placed to make it easy to see how the elements
interact;
look-it-up principle: class definitions including member variables for stable, frequently
requested information;
need-to-know principle, with public interfaces designed to restrict member-variable and
member-function access, thus facilitating the improvement and maintenance of
nonpublic program elements;
keep-it-simple principle: class and function definitions are broken up when these
definitions become too complex to understand;
modularity principle, with program elements divided into logically coherent modules.
Where to Read More
1. Documentation
2. Books
3. Internet
4. Source Code
Let`s try!
Inspired by Technology.
Driven by Value.
Find us at eleks.com Have a question? Write to eleksinfo@eleks.com

More Related Content

What's hot (20)

PPTX
Introduction to java
Veerabadra Badra
 
ODP
JavaFX in Action Part I
Mohammad Hossein Rimaz
 
ODP
Using Zend Framework 2 Book Presentation
olegkrivtsov
 
PDF
Introduction to java (revised)
Sujit Majety
 
PPTX
J2EE Struts with Hibernate Framework
mparth
 
PPT
Java for Recruiters
ph7 -
 
PPTX
Java Programming
Elizabeth alexander
 
PPTX
Spring presentation
Chandan Sharma
 
PPTX
Project Presentation on Advance Java
Vikas Goyal
 
PDF
Introduction to Java
Professional Guru
 
PPT
Spring ppt
Mumbai Academisc
 
PPTX
Groovy features
Ramakrishna kapa
 
PPT
Springboot introduction
Sagar Verma
 
PPTX
Java Introduction
javeed_mhd
 
PPTX
Great cup of java
CIB Egypt
 
PPTX
Introduction to java
Java Lover
 
PPTX
Introduction to java
Saba Ameer
 
PPT
Java Presentation
pm2214
 
PDF
Tellurium At Rich Web Experience2009
John.Jian.Fang
 
PDF
Introduction to Java
Professional Guru
 
Introduction to java
Veerabadra Badra
 
JavaFX in Action Part I
Mohammad Hossein Rimaz
 
Using Zend Framework 2 Book Presentation
olegkrivtsov
 
Introduction to java (revised)
Sujit Majety
 
J2EE Struts with Hibernate Framework
mparth
 
Java for Recruiters
ph7 -
 
Java Programming
Elizabeth alexander
 
Spring presentation
Chandan Sharma
 
Project Presentation on Advance Java
Vikas Goyal
 
Introduction to Java
Professional Guru
 
Spring ppt
Mumbai Academisc
 
Groovy features
Ramakrishna kapa
 
Springboot introduction
Sagar Verma
 
Java Introduction
javeed_mhd
 
Great cup of java
CIB Egypt
 
Introduction to java
Java Lover
 
Introduction to java
Saba Ameer
 
Java Presentation
pm2214
 
Tellurium At Rich Web Experience2009
John.Jian.Fang
 
Introduction to Java
Professional Guru
 

Similar to Lecture java basics (20)

PPTX
Unit1 introduction to Java
DevaKumari Vijay
 
PDF
Java chapter 1
Mukesh Tekwani
 
PPTX
Introduction to java
princeirfancivil
 
PPTX
Introduction to java
sanjay joshi
 
PPTX
Chapter One Basics ofJava Programmming.pptx
Prashant416351
 
PPTX
Getting Started with JAVA
ShivamPathak318367
 
PDF
What is java
javaicon
 
PPTX
Java Technologies notes of unit 1 and 2.
sumanyadavdpg
 
PPTX
Java Fundamentals in Mule
Anand kalla
 
PPTX
java tutorial for beginner - Free Download
TIB Academy
 
DOCX
java introduction.docx
vikasbagra9887
 
PPTX
Introduction to java
sanjay joshi
 
PDF
OOPS JAVA.pdf
DeepanshuMidha5140
 
PPTX
2 22CA026_Advance Java Programming_Data types and Operators.pptx
dolphiverma80
 
PPTX
Introduction to java
Phaniu
 
PPTX
Introduction to java
javeed_mhd
 
PPTX
Java in Mule
Shahid Shaik
 
PPTX
Java Basics in Mule
Rajkattamuri
 
PPTX
Java Basics
Khan625
 
PPTX
Java. converted (2)
AVINASHMEHRA6
 
Unit1 introduction to Java
DevaKumari Vijay
 
Java chapter 1
Mukesh Tekwani
 
Introduction to java
princeirfancivil
 
Introduction to java
sanjay joshi
 
Chapter One Basics ofJava Programmming.pptx
Prashant416351
 
Getting Started with JAVA
ShivamPathak318367
 
What is java
javaicon
 
Java Technologies notes of unit 1 and 2.
sumanyadavdpg
 
Java Fundamentals in Mule
Anand kalla
 
java tutorial for beginner - Free Download
TIB Academy
 
java introduction.docx
vikasbagra9887
 
Introduction to java
sanjay joshi
 
OOPS JAVA.pdf
DeepanshuMidha5140
 
2 22CA026_Advance Java Programming_Data types and Operators.pptx
dolphiverma80
 
Introduction to java
Phaniu
 
Introduction to java
javeed_mhd
 
Java in Mule
Shahid Shaik
 
Java Basics in Mule
Rajkattamuri
 
Java Basics
Khan625
 
Java. converted (2)
AVINASHMEHRA6
 
Ad

More from eleksdev (20)

PPTX
Communication in android
eleksdev
 
PPTX
Hello android world
eleksdev
 
PPTX
Angular. presentation
eleksdev
 
PPTX
Android location and sensors API
eleksdev
 
PPTX
Frontend basics
eleksdev
 
PPTX
Advanced styles
eleksdev
 
PPTX
Css animation, html5 api
eleksdev
 
PPTX
Improving rpc bkp
eleksdev
 
PPTX
G rpc lection1_theory_bkp2
eleksdev
 
PPTX
G rpc lection1
eleksdev
 
PPTX
Windows service
eleksdev
 
PPTX
Rpc
eleksdev
 
PPTX
DAL
eleksdev
 
PPTX
Aspnet core
eleksdev
 
PPTX
Web service lecture
eleksdev
 
PPTX
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
eleksdev
 
PPTX
SDLC. QA Role
eleksdev
 
PPTX
SDLC. UX Role
eleksdev
 
PPTX
SDLC. PM Role
eleksdev
 
PPTX
SDLC. BA Role
eleksdev
 
Communication in android
eleksdev
 
Hello android world
eleksdev
 
Angular. presentation
eleksdev
 
Android location and sensors API
eleksdev
 
Frontend basics
eleksdev
 
Advanced styles
eleksdev
 
Css animation, html5 api
eleksdev
 
Improving rpc bkp
eleksdev
 
G rpc lection1_theory_bkp2
eleksdev
 
G rpc lection1
eleksdev
 
Windows service
eleksdev
 
Aspnet core
eleksdev
 
Web service lecture
eleksdev
 
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
eleksdev
 
SDLC. QA Role
eleksdev
 
SDLC. UX Role
eleksdev
 
SDLC. PM Role
eleksdev
 
SDLC. BA Role
eleksdev
 
Ad

Recently uploaded (20)

PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
July Patch Tuesday
Ivanti
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
July Patch Tuesday
Ivanti
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 

Lecture java basics

  • 1. Java Basics by Yuriy Voznyak, Software Engineer eleks.com
  • 2. Lecture Goal or Why Java? ● Become familiar with one more great platform; ● Introduction to Android development; ● Understand the difference between Java and another popular languages such as C# or C++ ● 30 Billion Devices ● ...
  • 3. Why did Java invent? 1. Write Once, Run Everywhere. This old Sun slogan describes very ambitious goal. Sun wanted to create cross-platform language; 2. Java Virtual Machine should run every application in the separate sandbox with dedicated permission; So, applications and environment should provide better security than with using of unmanaged code 3. Easy distribution over Internet as Java applications or Java Applets; 4. Built-in Multithreading support; 5. To replace C/C++ with a better design;
  • 4. What do I need for Java? ● If I want to run Java applications on Desktop, there is a JRE (Java Runtime Environment); ● For servers there is another JRE - Server JRE (Server Java Runtime Environment). Contains tools for JVM monitoring and some tools required for server applications, but does not include browser integration (the Java plug-in), auto-update, nor an installer; ● I want to develop Java Software: need Oracle JDK (Java Development Kit). Includes a complete JRE plus tools for developing, debugging, and monitoring Java applications; ● I want to learn Java deeper or have some extra needs: there is open-source Java implementation called OpenJDK.
  • 5. Java Editions Java Standard Edition (Java SE) lets you develop and deploy Java applications on desktops and servers, as well as embedded environments. Most common used. Java Enterprise Edition (Java EE) Extended overset of java engine, contains specifications for designing and developing of Big Enterprise Network Applications Java Micro Edition (Java ME) a subset of Java, designed for devices with limited hardware characteristics. Java Embedded Edition Oracle`s marketing term. Contain some binaries to work with Raspberry Pi or ARM devboards Java DB Just a implementation of open-source database engine Java Card Technology to develop Smart Cards secure applets. Sooo limited and low-level Marketing sets Specialized
  • 7. Noticeable Java Feature Differences ● Syntax is a bit simpler. Really ● Packages instead of namespaces ● No default values ● Values are passed by value only. But, for reference types, value is reference. So, you just pass copy of the reverence: is able to modify but unable to assign another reference; ● Methods names begin from capital letter :) ● Observer patterns everywhere with anonymous classes ● Java runs not only on Windows ● Less syntax sugar
  • 8. Main Method C# static void Main(string[] args) … or even static void Main() Java public static void main(String[] args)
  • 10. Declaring Constants C# const int Constant = 42; Java [public] static final int CONSTANT = 42;
  • 11. Inheritance C# class Child : Parent, IDerivable { ... } Java class Child extends Parent implements Derivable { ... }
  • 14. Primitive Types type size range default value wrapper byte 1 From +127 to -128 0 Byte short 2 From +32,767 to -32,768 0 Short int 4 From +2,147,483,647 to -2,147,483,648 0 Integer long 8 From +9,223,372,036,854,775,807 to - 9,223,372,036,854,775,808 0L Long float 4 From 3.402,823,5 E+38 to 1.4 E-45 0.0f Float double 8 From 1.797,693,134,862,315,7 E+308 to 4.9 E-324 0.0d Double char 2 All Unicode characters 'u0000' Character boolean 1 False, true false Boolean
  • 15. Moar Difference ● In Java methods are virtual by default but you can make them final. (In C# they are sealed by default, but you can make them virtual.) ● Generics are completely different between the two; Java generics are just a compile-time "trick" (but a useful one at that). In C# and .NET generics are maintained at execution time too, and work for value types as well as reference types. ● Java doesn't allow the creation of user-defined value types ● Java doesn't support overloading ● Java doesn't have anything like LINQ ● Partly due to not having delegates, Java doesn't have anything quite like anonymous methods and lambda expressions (in Java 8 does). Anonymous inner classes usually fill these roles. ● Java doesn't have implicitly typed local variables (var directive)
  • 16. Please, stop! ● Java doesn't have extension methods ● The access modifiers are somewhat different - in Java there's (currently) no direct equivalent of an assembly, so no idea of "internal" visibility; ● Java doesn't have the equivalent of "unsafe" code ● Java has no preprocessor directives (#define, #if etc) ● Java has no equivalent of C#'s ref and out for passing parameters by reference ● Java has no equivalent of partial types ● Java has no unsigned integer types ● Java has no language support for a decimal type. However, java.math.BigDecimal provides similar functionality ● Java has no equivalent of nullable value types ● Java doesn't have static classes (which don't have any instance constructors, and can't be used for variables, parameters etc)
  • 17. Is it all? Of course, no. However… ● in C# there's no equivalent to the "default" visibility in Java which takes account of namespace ● C# interfaces cannot declare fields. In java interfaces can contain static final fields and even implementation (sic!) ● C# doesn't have checked exceptions ● C# doesn't have anonymous inner classes ● C# doesn't have Java's inner classes at all, in fact - all nested classes in C# are like Java's static nested classes
  • 18. How to write Java application? 1. 2.
  • 19. What is Jar JAR file is a file format based on the popular ZIP file format and is used for aggregating many files into one. A JAR file is essentially a zip file that contains an optional META-INF directory. A JAR file can be created by the command-line jar tool, or by using the java.util.jar API in the Java platform. There is no restriction on the name of a JAR file, it can be any legal file name on a particular platform. In many cases, JAR files are not just simple archives of java classes files and/or resources. They are used as building blocks for applications and extensions. The META-INF directory, if it exists, is used to store package and extension configuration data, including security, versioning, extension and services.
  • 20. Designing Classes Structure explicit-representation principle: classes included to reflect natural categories; no-duplication principle: member functions situated among class definitions to facilitate sharing; local-view principle: program elements placed to make it easy to see how the elements interact; look-it-up principle: class definitions including member variables for stable, frequently requested information; need-to-know principle, with public interfaces designed to restrict member-variable and member-function access, thus facilitating the improvement and maintenance of nonpublic program elements; keep-it-simple principle: class and function definitions are broken up when these definitions become too complex to understand; modularity principle, with program elements divided into logically coherent modules.
  • 21. Where to Read More 1. Documentation 2. Books 3. Internet 4. Source Code
  • 23. Inspired by Technology. Driven by Value. Find us at eleks.com Have a question? Write to [email protected]

Editor's Notes

  • #3: Java is not number one in Eleks though.
  • #4: Java is not number one in Eleks though.
  • #5: Java is not number one in Eleks though.
  • #14: No tuple