Dr. Manaswita Saikia
Dr. Manaswita Saikia
Manaswita Saikia
[email protected]
Chapter 1
Java Programming Fundamentals
Architecture neutral
compiled java programs will run on variety of
processors using various OSs (The goal- “ Write
once, run any where, any time, forever”)
Distributed
Designed for distributed environment of internet
because it handles TCP/IP protocol, RMI
Security
Execution is confined to JVM
Java and Internet
Java can be used to create two types of
programs: applications and applets
An application is a program
that runs on your computer, under the
operating system of that computer
An applet is a tiny Java program
designed to be transmitted over the Internet
automatically downloaded across the network,
just like an image, sound file, or video clip
executed by a Java-compatible Web browser
Applets
• Applets
• Allow some functionality to be moved from server
to client like
• display data provided by the server
• handle user inputs
• provide simple functions ( loan
calculator)
that execute locally rather than on server
var2 = var1 / 2;
System.out.print("var2 contains var1 / 2: ");
System.out.println(var2);
}
}
Copyright © 2013 by The McGraw-Hill Companies, Inc. All
rights reserved.
A Third Example
class Example3 {
public static void main(String[] args) {
int w; // declare an int variable
double x; // declare a floating-point variable
• Example:
if(3 < 4) System.out.println("yes");
• Relational operators:
<, >, <=, >=, ==, !=
if(a < b)
System.out.println("a is less than b");
• Example:
if(w < h) {
v = w*h;
w = 0;
}
Example 1
//This is an example of single line comment
Example 2
/*This is my first java program.
This will print 'Hello World‘
as the output
*/
Indentation Practices
• The Java compiler doesn’t care about
indentation.
abstract assert boolean break byte case catch char class const
new package private protected public return short static strictfp super
switch synchronized this throw throw transient try void volatil while
s e
• Legal identifiers
• Test , x, y2, maxLoad, sample34, $up, _top
Java class Libraries
• A package which gets imported
automatically to all the java programs
• ‘java.lang’