Category Archives: Java

java.lang.System.arraycopy() method

java.lang.System class provides useful methods for standard input and output, for loading files and libraries or to access externally defined properties. The java.lang.System.arraycopy() method copies a source array from a specific beginning position to the destination array from the mentioned position. No. of arguments to be copied are decided by len argument. The components at source_Position… Read More »

java.lang.Boolean class methods

About : java.lang.Boolean class wraps primitive type boolean value in an object. Class Declaration public final class Boolean extends Object implements Serializable, Comparable Constructors : Boolean(boolean val) : Assigning Boolean object representing the val argument. Boolean(String str) : Assigning Boolean object representing the value true or false according to the string. Methods : booleanValue() :… Read More »

Exceptions in Java

What is an Exception? An exception is an event, which occurs during the execution of a program i.e at run time, that disrupts the normal flow of the program’s instructions. When an error occurs in a method, the method creates an Object known as Exception Object and hands it off to the runTime system. The… Read More »

Creating a file using FileOutputStream

FileOutputStream class belongs to byte stream and stores the data in the form of individual bytes. It can be used to create text files. A file represents storage of data on a second storage media like a hard disk or CD. Whether or not a file is available or may be created depends upon the… Read More »

A Group chat application in Java

In this post, a group chat application using MulticastSocket (Java Platform SE 7) class is discussed. A MulticastSocket is a (UDP) DatagramSocket, with additional capabilities for joining “groups” of other multicast hosts on the internet. Implementation Save the file as GroupChat.java and compile it using javac and then run the program using two command line… Read More »

Arrays in Java

An array is a container object that holds a fixed number of values of a single data type. This is different from C/C++ where array name represents an address. Length of an array is fixed when it is created (Note that we are talking about simple arrays here, not dynamic arrays like ArrayList) Since arrays… Read More »

Wrapper Classes in Java

A Wrapper class is a class whose object wraps or contains a primitive data types. When we create an object to a wrapper class, it contains a field and in this field, we can store a primitive data types. In other words, we can wrap a primitive value into a wrapper class object. Need of… Read More »

Anonymous Inner Class in Java

It is an inner class without a name and for which only a single object is created. An anonymous inner class can be useful when making an instance of an object with certain “extras” such as overloading methods of a class or interface, without having to actually subclass a class. Anonymous inner classes are useful… Read More »

Different ways of Method Overloading in Java

Prerequisite- Overloading Java can distinguish the methods with different method signatures. i.e. the methods can have same name but with different parameters list (i.e. number of the parameters, order of the parameters, and data types of the parameters) within the same class. Overloaded methods are differentiated based on the number and type of the parameters… Read More »

Jar files in Java

A JAR (Java Archive) is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file to distribute application software or libraries on the Java platform. In simple words, a JAR file is a file that contains compressed version of .class files, audio… Read More »

Types of References in Java

In Java there are four types of references differentiated on the way by which they are garbage collected. Strong References Weak References Soft References Phantom References Prerequisite: Garbage Collection Strong References: This is the default type/class of Reference Object. Any object which has an active strong reference are not eligible for garbage collection. The object… Read More »