admin

Search, Append and Insert StringBuffer Methods

Very often used many StringBuffer Methods are discussed with Examples and Screenshots in Simple terms for a Beginner. StringBuffer Methods for Searching characters The indexOf(), lastIndexOf() and charAt() methods existing in String class also exist in StringBuffer class. They can be used with StringBuffer object. The meaning of the methods is just same of String …

Search, Append and Insert StringBuffer Methods Read More »

StringBuffer substring Java Pass By Reference

StringBuffer substring Java Pass By Reference Many petty methods exist with StringBuffer like substring(), setLength() and trimToSize() etc. These methods are not much used in regular programming. public class MiscellaneousMethods { public static void main(String args[]) { // using substring(), to extract part of a string StringBuffer buffer1 = new StringBuffer(“TajMahal”); String s1 = buffer1.substring(3); …

StringBuffer substring Java Pass By Reference Read More »

Hierarchy Exceptions Checked Unchecked Exceptions

Hierarchy of Exceptions (Checked Unchecked Exceptions) After knowing exceptions and exception handling mechanism, let us explore how many exceptions exist, are they inheriting from a common super class, any classification exists or not etc. Whenever you come across a new Java class, it is essential to know its super classes, so that, you can use …

Hierarchy Exceptions Checked Unchecked Exceptions Read More »

Interfaces Multiple Inheritance Java

We know earlier, Java does not support multiple inheritance, basically. But to support multiple inheritance, partially, Java introduced "interfaces". An interface is not altogether a new one for us; just it is a special flavor of abstract class where all methods are abstract. That is, an interface contains only abstract methods. Syntax of multiple inheritance …

Interfaces Multiple Inheritance Java Read More »

Constructors and Constructor overloading

A constructor looks more like a method but without return type. Moreover, the name of the constructor and the class name should be the same. The advantage of constructors over methods is that they are called implicitly whenever an object is created. In case of methods, they must be called explicitly. To create an object, …

Constructors and Constructor overloading Read More »

Applet Example Draw Strings and Graphics

Applet Example: Drawing Strings and Graphics in Applets given with Screenshots in Simple terms for a Beginner. After practicing the earlier simple life cycle program, let us write another program that prints some strings on applet window (not at DOS prompt as done previously). Now we use the java.awt.Graphics object passed as parameter to paint() …

Applet Example Draw Strings and Graphics Read More »

StringTokenizer Tokenizing String

After knowing the data structures from java.util package, let us discuss about the remaining classes of java.util package. The classes include Date and GregorianCalendar to manipulate dates, Random class to generate random numbers and StringTokenizer to separate the string into individual words (known as tokens). The other classes less used are Observer, Observable, Timer and …

StringTokenizer Tokenizing String Read More »

Shallow Copying Vs Deep Copying Copying an Object

Shallow Copying Vs Deep Copying: Copying an object involves getting another object with the same properties of the original. Here, there exists two ways – two objects having their own set of properties (instance variables) or both objects referring the same location of properties. Following gives the detailed discussion. Shallow Copying Shallow copying is the …

Shallow Copying Vs Deep Copying Copying an Object Read More »

Inner classes Java

Introduction to Inner classes Java JDK 1.1 introduced a new type of classes known as inner classes. All the classes you have done so far are known as top-level classes. A class written inside another class is known as "inner class" or "nested class". That is, an inner class is enclosed within another class. Inner …

Inner classes Java Read More »

Garbage Collection gc() exit(0)

Garbage Collection gc() exit(0) Summary: In this "Garbage Collection gc() exit(0)", the basics of garbage collection focusing the methods gc() and exit(0) illustrated. More on Garbage Collection gc() exit(0) methods Unwanted (not used in the remaining part of the program) objects generated in the process are known as garbage. Java includes a special built-in style …

Garbage Collection gc() exit(0) Read More »

Communication with TCP/IP Protocol Java

Java is very strong in communication world. To support, LAN programming, the java.net package comes with two classes Socket and ServerSocket. The meaning and purpose these classes and network related basics, you have studied in Networking – Introduction. Socket and ServerSocket are extensively I/O streams for data traversal and for this reason, sockets are called …

Communication with TCP/IP Protocol Java Read More »