Basic Java Programming Tutorial
Basic Java Programming Tutorial
Basic Java Programming Tutorial
TUTORIAL
History
James Gosling and Sun Microsystems
Oak
Java, May 20, 1995, Sun World
Hot Java
– The first Java-enabled Web browser
JDK Evolutions
JDK Editions
Java Standard Edition (J2SE)
J2SE can be used to develop client-side standalone applications or
applets.
Java Enterprise Edition (J2EE)
J2EE can be used to develop server-side applications such as Java
servlets and Java Server Pages.
Java Micro Edition (J2ME).
J2ME can be used to develop applications for mobile devices such
as cell phones.
Java isn't C!
In C, almost everything is in functions
In Java, almost everything is in classes
There is often only one class per file
There must be only one public class per file
The file name must be the same as the name of that
public class, but with a .java extension
Why Java?
It’s the current “hot” language
It’s almost entirely object-oriented programming
It has a vast library of predefined objects and
operations
It’s more platform independent
-this makes it great for Web programming
It’s more secure
It isn’t C++
Java Virtual Machine
The .class files generated by the compiler are
not executable binaries
– so Java combines compilation and interpretation
Instead, they contain “byte-codes” to be
executed by the Java Virtual Machine
– other languages have done this, e.g. UCSD Pascal
This approach provides platform
independence, and greater security
A Picture is Worth…
Java Applications and Java … lets
Stand-alone Applications
Just like any programming language
Applet
Run under a Java-Enabled Browser
Midlet
Run in a Java-Enabled Mobile Phone
Servlet
Run on a Java-Enabled Web Server.
Write Once, Run Anywhere
Main OOP Concepts:
Inheritance
Abstraction
Encapsulation
Polymorphism
Event-driven computations
Characteristics of Java
Java is simple
Java is object-oriented
Java is distributed
Java is interpreted
Java is robust
Java is secure
Java is architecture-neutral
Java is portable
Java’s performance
Java is multithreaded
Java is dynamic
What is a class?
• A class consists of
– a collection of fields, or variables,
very much like the named fields of a
struct
– all the operations (called methods)
that can be performed on those fields
– can be instantiated
• A class describes objects and
operations defined on those
objects
Method Declarations
}
}
The “Welcome to java”
Application
A Simple Application
Example
//This application program prints Welcome
//to Java
To execute, run the Java VM and include the name of the class which
contains the "main" method as the first command line parameter.
www.playppt.com