Java Input and Output

JAVA STREAMS Streams provide the data transfer mechanism on top of sockets. To use a telephone structure, sockets are like the telephone connection and streams are like voice exchanges. When you speak to a friend on the telephone, you create an output stream; your voice is picked up on the receiving end by an input […]

Java String Handling

String Handling   In Java a string is a sequence of characters. Java implements strings as objects of type String. For example, Java has methods to compare two strings, search for a substring, concatenate two strings, and change the case of letters within a string. Also, String objects can be constructed a number of ways. […]

Java Multithreading

Multithreaded Programming   Java provides built-in support for multithreaded programming. A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution. A process is, in essence, a program that is executing. In a thread-based multitasking […]

Java Exception Handling

Exception Handling   An exception is an abnormal condition that arises in a code sequence at run time. In other words, an exception is a run-time error. In computer languages that do not support exception handling, errors must be checked and handled manually typically through the use of error codes, and so on. This approach […]

Java Interfaces

Interfaces   Using the keyword interface, you can fully abstract a class’ interface from its implementation. That is, using interface, you can specify what a class must do, but not how it does it. Interfaces are syntactically similar to classes, but they lack instance variables, and their methods are declared without any body. Once it […]

Java Inheritance

Inheritance   Inheritance is one of the foundations of object-oriented programming because it allows the creation of hierarchical classifications. Using inheritance, you can create a general class that defines behavior common to a set of related items. This class can then be inherited by other, more specific classes, each adding those things that are unique […]

Java Methods and Classes

A Closer Look at Methods and Classes Overloading Methods In Java it is possible to define two or more methods within the same class that share the same name, as long as their parameter declarations are different. When this is the case, the methods are said to be overloaded, and the process is referred to […]

Java Classes

Introducing Classes   The class is at the core of Java. The class forms the basis for object-oriented programming in Java. Any concept you wish to implement in a Java program must be encapsulated within a class.   Class Fundamentals The classes created in the preceding chapters primarily exist simply to encapsulate the main( ) […]

Java Control Statements

Control Statements   A programming language uses control statements to cause the flow of execution to advance and branch based on changes to the state of a program. Java’s program control statements can be put into the following categories: selection, iteration, and jump. Selection statements allow your program to choose different paths of execution based […]

Java Operators

Operators   Java provides a rich operator environment. Most of its operators can be divided into the following four groups: arithmetic, bitwise, relational, and logical.   Arithmetic Operators Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. The following table lists the arithmetic operators:     The […]