Java

Let’s learn how to rename file in java. How to rename file in java To rename a file renameTo() method is used of File class. Here’s the syntax of renameTo() method of File class. public boolean renameTo(File dest) renameto method returns true if and only if the renaming is succeeded; false otherwise. Many aspects of…

Read More How to rename file in java

Let’s learn random number generator in java. Random number generator in java Let’s learn how to generate random numbers in java using some built in methods and classes. Math.random() method in java Random function in java returns pseudo random double greater than or equal to 0.0 and less than 1.0. Math.random() method uses Random class…

Read More Random number generator in java

Let’s learn quicksort in java. Quicksort in java Basically quicksort is a divide and conquer algorithm. Quicksort is one of the widely used sorting algorithm. Because it is used to sort large datasets or lists. Quicksort in java implementation Below are steps on quicksort algorithm java. Given an array of numbers we want to sort…

Read More Quicksort in java

Let’s learn merge sort in java. Merge sort in java Merge sort is divide and conquer algorithm. In merge sort, given array is divided into two smaller portions. To divide a collection, take the middle of collection and split into two smaller lists. These two smaller portions are again recursively splitted till they are broken…

Read More Merge sort in java

Let’s learn 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 element is…

Read More Linear search in java

Let’s learn insertion sort in java. Insertion sort in 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 have an…

Read More Insertion sort in java

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

Read More If else in java

Let’s learn garbage collection in java. Garbage collection in java Garbage collection is the process of deleting unreferenced objects in programs automatically by Garbage Collector(GC). Garbage collector finds unused/unreferenced objects from heap memory and deletes them to reclaim memory. In C/C++ programmer is responsible to manage memory. That is programmer is responsible for both creation…

Read More Garbage collection in java

Let’s learn for loop in java. for loop in java for loop executes a block of statements until condition evaluates to true. Use for loop if you know the number of iteration is fixed. Syntax for(initialization; condition; increment/decrement) { // body } For loop is a combination of three parts: initialization, condition and increment/decrement. Here’s…

Read More for loop in java