Java

Let’s learn 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” will execute. Here’s the syntax for if else statement. Syntax: if(condition) { // if condition is true; } else { // if condition…

Read More if else in java

Let’s learn 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 in the…

Read More Garbage collection in java

Let’s learn 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 in java executes…

Read More for loop in java

Let’s learn how to delete a directory in java. How to delete a directory in java To delete a directory use delete() method of File class. delete() method deletes file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted. delete()…

Read More How to delete a directory in java

Let’s learn java create new file. Java create new file In this post we are going to learn to create a new file using createNewFile() method of File class which creates a new, empty file and returns a boolean value. In creating a file, first create File object then call createNewFile() method to create new…

Read More Java create new file

Let’s learn how to create directory in java. How to create directory in java how to create folder in java is most frequently asked java interview question. There are two methods to create directory. They are mkdir() and mkdirs() of class File which returns boolean value. mkdir() method create single directory. File directory = new…

Read More How to create directory in java

Let’s learn continue statement in java. continue statement in java When continue statement is encountered inside a loop then control jumps to the beginning of the loop for next iteration instead of executing remaining or following statements of current iteration. continue statement in java is used in many loop control structures. continue keyword in java…

Read More continue statement in java

Let’s learn bubble sort in java. Bubble sort in java what is bubble sort in java? Bubble sort is considered as simplest sorting algorithm for the fact that given array is traversed from first to last element. And while traversing, current element is compared with adjacent element and if current element is greater than the…

Read More Bubble sort in java

Let’s learn binary search in java. Binary search in java Binary search is the process of searching key element from sorted array. binary search algorithm java As you can see in the below image we have a sorted array of size 5. Now given an array, we have to find whether key element exist in…

Read More Binary search in java

Let’s learn system arraycopy() method in java. System arraycopy() method in java Arraycopy method copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array. Using arraycopy() method subsequence array components are copied from source array referenced by source to the destination array referenced by…

Read More System arraycopy() method in java