Let’s learn what is linear search in java? Linear search in java Linear search is very simple sequential search algorithm. It’s used to search key element in the given array. Here search starts from leftmost element of an array and key element is compared with every element in an array. Search continues until the key…

Read More Linear search in java

Let’s learn what is the insertion sort in java? Insertion sort java Insertion sort sorts elements the way in which we sort playing cards. This sort can be fast when used with smaller arrays. Given an array of elements, let’s sort them in increasing order. So let’s look at sample list of integer elements. We…

Read More Insertion sort java

Let’s learn what is if else in java? If else in java If else statement java executes a block of code where; statements inside “if” executes if condition is true else statements inside “else” execute. Here’s the syntax for if else statement. Syntax: if(condition) { // if condition is true; } else { // if…

Read More If else in java

Let’s learn java convert hex to decimal. Java convert hex to decimal In hexadecimal to decimal conversion we are using Integer.parseInt() method. Integer.parseInt() method parses string argument as a signed integer in the radix specified by the second argument. Here’s the syntax. public static int parseInt(String s, int radix) throws NumberFormatException Here’s the program to…

Read More Java convert hex to decimal

Let’s learn what is garbage collection in java. Garbage collection in java Garbage collection means destroying or de-allocating unused objects in memory. Objects which are not used or has no references can be reclaimed. Garbage collector is used to reclaim unused memory automatically. Java handles memory de-allocation automatically since object once created uses some memory…

Read More Garbage collection in java

Let’s learn what is a for loop in java? For loop in java For loop is used to iterate a block of statements multiple times. Use for loop if you know the number of iteration is fixed. Here are three types of loops in java with example, While loop Do while loop For loop Loops…

Read More For loop in java

Let’s learn how do you write a factorial program in java? Factorial program in java Find factorial of a number in java is one of the common java interview question. Factorial is the product of all integers less than or equal to given number. Denoted as n! For example, 6! = 6 * 5 *…

Read More Factorial program in java