Simple java program to add two numbers

java program to add two numbers is a very simple program. It is required by learners How can we add two numbers. We will start with simple addition and try to cover additional things here. Simple java program to add two numbers Steps to add two numbers Store two numbers in two variables Add both … Read more

Java swing login form with database connection source code download

Here we will develop the Java swing login form with database connectivity. We considered a small example with student details to log in From Java Swing and redirect to another frame after login. Java swing login form with database connection in Netbeans Here we have created a swing login form in java and connected that … Read more

How to static import math class in Java

Here we will see how can we import math class in Java. As we already know to import any class from any package we use the following notation import packagename.classname; example import java.util.Scanner; Here java is package util is subpackage and Scanner is a class. By importing the Scanner class we can use all its … Read more

Java Finding a sub string in string

indexOf(String str) return int value that is the index value of str if found in string other wise it returns -1.The index value start from 0. contains(CharSequence str) returns boolean value if str is present in given string it will return true else false.

How to Convert Java Object to/from JSON using GSON

Gson is Java JSON library that is used to convert Java object to/from JSON GSON is developed by google. GSON Maven dependency is as below

You can also download Gson Jar from here Gson jar contains API to work with JSON GOal of GSON is provide simple methods to convert and receive JSON, Provides … Read more

for, while, do while and for each loops in Java

In a programming language we have to repeat set of instruction many time as per programmer’s requirements. To repeat instructions java provides looping statements. Looping is also known as Iterative statementFollowing are types of loop in java.1. For loop statement2. While loop statement3. Do while loop statement4. For each loop (enhanced for loop) Work of … 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

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

Prime number program in java using for loop

Prime number program in java using for loop is very simple. we already discussed the prime number example with the while loop. Prime number program in java using for loop

Prime Number Between Given Range In Java using for loop

Contains list java contains() in Java ArrayList

In Java, the term “contains list java” is used to check whether a particular object or element is present in a list or collection. The ArrayList method contains() is used to check specified elements in List. Contains Syntax public boolean contains​(Object o) Parameters: The method takes a single parameter, which is the object or element that you want … Read more