Applet Life Cycle in Java with Example

Applet in Java Applet in Java is a special Java program that are primarily used in a internet programming. Applet Life Cycle is very important to know in Java Applet Programming.  As we have already seen how to run program from command prompt, but there were no GUI. To provide Graphical user interface(GUI) Java Applet … Read more

Exception Handling in Java: Hierarchy Example and Types

One of the important topic Exception handling in java Here we will discuss basics of exceptions, Why Exception handling and its types. What is Exception in Java A unwanted event that disrupts the program execution. In Java all Exceptions are class. Why Exception Occurs Due to wrong user input Incorrect programming logic Example of Exceptions … Read more

Leap Year Program in Java

A Leap Year is a year that has 366 days. This year February is of 29 days. Leap years occur in every four years. A leap year has the following constraints. We can check Leap Year Program in Java as below A year is divisible by 400 then it is a leap year A year … Read more

How to find String length in java string method

Get String length with String length() method To find String length in java there is a method length(). This method is used to get the length of the string. The signature of length method is:

The length method returns the length of the string. it counts the number of Unicode in string. str.length java … Read more

Byte Streams in Java

In java programming, to perform input and output of 8-bit, Byte stream is used. Most common byte streams classes are, FileInputStream and FileOutputStream. FileInputStream : FileInputStream is used for reads one byte at a time . FileOutputStream : FileOutputStream is used for writes one byte at a time Writing Bytes Example: Write a program, to write a bytes to … Read more

Inheritance in Java-Types and Examples

Inheritance in Java is the process of acquiring the properties of one class object into another class object. It allows the hierarchical classification. Inheritance also provides the facility of reusability. In Java programming, a class that is inherited is called a superclass or sub class or parent class and class that does the inheriting is … Read more

String in Java- Constructor methods and examples

Java String is defined in java.lang.String. Java String is a sequence of characters quoted in double quote (” “). Java String Constructors Sr No Constructor and description 1 String() Create a new empty string object 2 String(byte[] bytes) Construct a string object with byte array 3 String(char[] value) Construct a string object with character array … Read more

Producer Consumer Problem in Java

In computing, producer–consumer problem is also known as the bounded buffer problem. In the producer–consumer problem there are two processes, first is the producer and the second is the consumer, who share a common, fixed-size buffer.  The producer’s job is to generate data, put it into the buffer and start again. At the same time, … Read more

DataInputStream and DataOutputStream for primitive data

In java, a basic input-output stream provides a method for reading & writing bytes or characters in a file. If we want to read-write primitive data types (such as int, float, etc.) then we can use filter classes to filter data in the original stream. DataInputStream & DataOutputStream are two filter classes used for creating … Read more

Write a java program to reverse a string

We are discussing java program to reverse a string using following ways Java program to reverse a string using StringBuffer or StringBuilder class Java program to reverse a string using Loops(Iteration) Java program to reverse a string using StringBuffer or StringBuilder class

Output

Java program to reverse a string using Loops(Iteration) Copy and … Read more