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

Leap Year Program in Java

A Leap Year is a year which has 366 days. This year February is of 29 days. Leap years occurs in every four years. A leap year has following constraints. We can check in programming as below A year is divisible by 400 then it is a leap year A year is divisible by 4 … 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

Thread stop method in Java

In java, stop()  method  kills/terminates  the currently executing thread.

Result

Description: in the above program, when value of variable i=3 then stop() method terminates the curently executing thread and come out of the loop.

Thread Yield method in Java

In java, yield()  method  temporarily pause  the currently executing thread object  and allow other threads to execute.

Basics of Applet in Java

The Java Applet is a special Java program that are primarily used in a internet programming. Applet program runs on a web browser at client side. Applet program are used to make the web site more dynamic. Applet program embedded in a HTML page and hosted on a web server. Applet Skeleton/ Structure Applet skeleton … 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

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

Employee details program in java

Employee details program in java as as below. Here two classes are created Employee class EmployeeMain class Details of these two classes are as below Employee.java This class contains various field of employees like id, fname, lname, address etc. Its corresponding getter and setter method is created in program. Employee.java is a java bean and … 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