You are on page 1of 13

Introduction to JAVA

Java is…

 The #1 programming language and development platform


 It reduces costs
 Shortens development timeframes
 Drives innovation
 Improves application services
 Continues to be the development platform of choice for enterprises and
developers
Prerequisites
To successfully complete this course, you must know how to:
 Compile and run Java applications
 Create Java classes
 Create object instances by using the new keyword
 Declare Java primitive and reference variables
 Declare Java methods by using return values and parameters
 Use conditional constructs such as if and switch statements
 Use looping constructs such as for, while, and do loops
 Declare and instantiate Java arrays
 Use the Java Platform, Standard Edition API Specification (Javadocs)
Class Introductions

Briefly introduce yourself:


 Name
 Title or position
 Company
 Experience with Java programming and Java applications
 Reasons for attending
Java Programs Are Platform-Independent
Platform-Independent Programs

 Java technology applications are written in the Java programming


language
 Compiled to Java bytecode
 Bytecode is executed on the Java platform
 The software that provides you with a runnable Java platform is called a
Java Runtime Environment (JRE)
 A compiler, included in the Java SE Development Kit (JDK), is used to
convert Java source code to Java bytecode.
Java in Server Environments

Java is common in enterprise


environments:
 Oracle Fusion Middleware
 Java application servers
 GlassFish
 WebLogic

 Database servers
 MySQL
 Oracle Database
OpenJDK

OpenJDK is the open-source implementation of Java:


 http://openjdk.java.net/
 GPL licensed open-source project
 JDK reference implementation
 Where new features are developed
 Open to community contributions
 Basis for Oracle JDK
Java Class Structure
Java Class Structure
A Java class is described in a text file with a .java extension. In the example shown, the Java
keywords are highlighted in bold
 The package keyword defines where this class lives relative to other classes, and provides a level of
access control. You use access modifiers (such as public and private) later in this lesson.
 The import keyword defines other classes or groups of classes that you are using in your class. The
import statement helps to narrow what the compiler needs to look for when resolving class names used
in this class.
 The class keyword precedes the name of this class. The name of the class and the file name must
match when the class is declared public (which is a good practice). However, the keyword public in
front of the class keyword is a modifier and is not required.
 Variables, or the data associated with programs (such as integers, strings, arrays, and references to
other objects), are called instance fields (often shortened to fields).
 Constructors are functions called during the creation (instantiation) of an object (a representation in
memory of a Java class).
 Methods are functions that can be performed on an object. They are also referred to as instance
methods.
A Simple Class
A simple Java class with a main method:
Java Naming Conventions
Code Blocks
 Every class declaration is enclosed in a code block
 Method declarations are enclosed in code blocks
 Java fields and methods have block (or class) scope
 Code blocks are defined in braces:

Example:

You might also like