Default value of string in Java

In Java, the default value for a String variable is null. When a String the variable is declared but not assigned a value, it automatically takes the null value. Here’s an example:

In the above example, the str variable is declared but not initialized with any value. Therefore, its default value is null. How … Read more

Sending mail using java mail API

Java Mail API is a platform and protocol independent framework to send mail. It supports JDK 1.4 and above. It supports IMAP, POP3 and SMTP protocol. To use Java Mail API we have to include javax.mail.jar in your class library.

for this java mail api should be present on your class path.

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

How to do pagination in JSP with Servlet JDBC and MYSQL

How to do pagination in JSP is very interesting concept let see step by step. What is Pagination? Pagination in programming refers to dividing an extensive data set into smaller, more manageable chunks called pages. It is commonly used when working with databases or APIs to efficiently handle large amounts of information. Advantages of Pagination? … Read more

Static keyword in Java with uses and Examples

Static keyword can be used with Variables Methods Blocks Static inner class lets see them one by one Static Variables in Java Static variable can be create by adding static keyword in front of variable. below count is static variable. A static variable is shared among all objects of class. Each class have their own … 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

Java program to swap two numbers

Java program to swap two numbers is a very basic example and can be used in any programming language. This is a beginner-level question for all programmers. Here different ways are given for swapping two numbers. All below java programs shows only method to implement this. Swapping of two numbers can be done in any … Read more

One dimensional array in java with examples

Here we will discuss One dimensional array in java and cover basic examples What is One dimensional (Single dimensional) array in java An array is a collection of similar elements. All array elements are stored in the contiguous memory location. One dimensional or single-dimensional array is an array with one dimension. One dimensional array declaration … 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