Java tutorials

22 lessons. Start at the top and work down.

Lesson 1

Unicast Remote Object Interface

Unicast Remote Object The UnicastRemoteObject class defines a non-replicated remote object whose references are valid only while the server process…

Lesson 2

Java Introduction: Your First Hello World Program

Every Java program starts from a class and a main method. The first program below prints a message on the screen. class HelloWorld declares a class…

Lesson 3

Java Data Types: int, float, double and More

Java has two types for decimal numbers. float uses 32 bits and needs an f at the end of a value, for example 10.8f . double uses 64 bits and is more…

Lesson 4

Java Programming Constructs: if, switch and Loops

Example 1 : IfDemo import java.*; class IfDemo { public static void main(String args[]) { int a=10; if(a>0) { System.out.println("A is positive"); }…

Lesson 5

Arrays in Java: Declare, Initialise and Use

Example : ArrayDemo import java.io.*; class ArrayDemo { int i; int arr[]={1,2,3,4,5,6,7,8,9,10}; void result() { System.out.println("Array details…

Lesson 6

String Class in Java: Methods and Examples

Example : MakeString import java.io.*; class MakeString { public static void main(String args[]) { char c[]={'j','a','v','a'}; String s1=new…

Lesson 7

Object Oriented Programming in Java: Classes and Objects

The General Form of a Class in Java... Example 1 : BoxDemo import java.io.*; class Box{ double width; double height; double depth; } class BoxDemo{…

Lesson 8

Methods in Java: Define, Call and Overload

Calling Methods... Example : BoxDemo import java.io.*; class Box { double width; double height; double depth; } class BoxDemo{ public static void…

Lesson 9

Constructors in Java: Types with Examples

Types of Constructors in java ... Example : Person import java.io.*; class Person { String name; int age; Person() { name="Unknown"; age=0; }…

Lesson 10

Inheritance in Java: extends, super and Examples

Inheritance Basics... Example : SimpleInheritance import java.io.*; class A { int i,j; void showij(){ System.out.println("i ana j:"+i+""+j); } }…

Lesson 11

Interfaces and Packages in Java

Implementing Interfaces in Java... Example : Program to illustrate interfaces import java.io.*; interface Area { final static double pi=3.14; double…

Lesson 12

Java util Package: StringTokenizer, Vector and Hashtable

String Tokenizer in Java... Example : STDemo import java.util.StringTokenizer; class STDemo { static String in ="title=java:The Complete…

Lesson 13

Exception Handling in Java: try, catch and finally

Using try and catch in Java... Example : TryDemo import java.io.*; class TryDemo { public static void main(String args[]) { int d=0; int a; try {…

Lesson 14

Java File Handling: Streams and File Class

Demonstrate File... Example : FileDemo First create a new file called COPYRIGHT under a new folder called java. import java.io.*; class FileDemo {…

Lesson 15

Java Reader and Writer Classes: Read and Write Files

Reader and Writer Classes FileReader in Java ... Example : FileReaderDemo import java.io.*; class FileReaderDemo { public static void main(String…

Lesson 16

Java Applet Basics: Create and Run an Applet

PASSING PARAMETERS TO APPLET... Example : BarChart extends Applet import java.awt.*; import java.applet.*; /*<applet code="BarChart.java" width=300…

Lesson 17

Event Handling in Java: Mouse and Keyboard Events

Handling Mouse Events in Java... Example : MouseEvents import java.awt.*; import java.awt.event.*; import java.applet.*; /* <applet…

Lesson 18

Java AWT Tutorial: Labels, Buttons and Text Fields

ILLUSTRATING LABEL CLASS IN JAVA.... Example : Labels import java.applet.*; import java.awt.*; /*<applet code="Labels"width=200 height=200> </applet>…

Lesson 19

Java AWT Layouts: FlowLayout, GridLayout and BorderLayout

Flow Layout in Java... Example : FlowLayoutDemo import java.applet.*; import java.awt.*; /* <applet code="FlowLayoutDemo" width=300 height=200>…

Lesson 20

Multithreading in Java: Create and Manage Threads

Creating a Thread... Example : ThreadDemo import java.io.*; class NewThread implements Runnable { Thread t; NewThread() { t=new Thread(this,"Demo…

Lesson 21

Java Networking: TCP/IP Sockets and Datagrams

TCP/Ip Client Sockets Server Program import java.net.*; import java.lang.*; import java.io.*; public class Server { public static final int…

Lesson 22

Java URL Class: Parse a URL with Examples

Java can read the parts of a web address (URL) with the URL class from the java.net package. A URL has a protocol, a host, a port, a file path and a…

WhatsApp us