Magic Number in Java

Magic Number is a number whose sum of the digits when recursively added to the point that a single digit is obtained, comes out to be 1. For example, consider the number 1882. Sum of the digits in the first iteration for 1882: 1 + 8 + 8 + 2 = 19. Sum of the digits in second iteration for 19: 1 + 9 = 10. We have still not obtained a single digit sum. Let’s sum the digits again.

Read more

RSA Algorithm in Java (Encryption and Decryption)

The term RSA is an acronym for Rivest-Shamir-Adleman who brought out the algorithm in 1977. RSA is an asymmetric cryptographic algorithm which is used for encryption purposes so that only the required sources should know the text and no third party should be allowed to decrypt the text as it is encrypted. RSA works on the fact that it is very hard to factorize large numbers (order of 100+ digits). The term “Asymmetric” signifies that there are two keys public

Read more

Java FizzBuzz Program

In this article, we’ll talk about what is FizzBuzz and how to implement FizzBuzz in Java. What is FizzBuzz? FizzBuzz is a group game for children to understand the concept of division and multiplication. In which, each child counts the numbers (starting from 1) following these rules: if that number is divisible by ‘3’ then replace the number by word fizz. If that number is divisible by ‘5’ then replace the number by word buzz. In case that number is

Read more

Infinite Loop in Java

Infinite loop in java refers to a situation where a condition is setup so that your loop continues infinitely without a stop. A loop statement is used to iterate statements or expressions for a definite number of times but sometimes we may need to iterate not for a fixed number but infinitely. For such situations, we need infinite loops in java. There are basically three looping structures in java: for, while and do while. These structures are used for iterations

Read more

Convert String to Byte Array or Byte Array to String in Java

Sometimes we need to convert Strings into Bytes because of several reasons like, to save content to the file, sending data over a network or it can be any other reason. So in this tutorial we’ll see how we can convert string to byte array or byte array to string in Java. Convert String to Byte Array in Java Method 1: Using String.getBytes()

Output: Platform’s encoding = [[email protected] Contents of byte Array = [84, 104, 101, 32, 67, 114,

Read more

6 Best Lightweight Java IDEs

When it comes to write code in any language, all of us choose an IDE to write the code because of the syntax highlighting, auto-complete, editing and running in the same environment (without using any extra command prompt to run the code), in-built debugger, reduced setup time etc. If we want to write code in Java, the names of IDEs that comes into our minds are – NetBeans, Eclipse, IntelliJ IDEA. Which are really good IDEs to work in Java.

Read more

Java Delay – 4 Ways to Add Delay in Java

Let’s discuss about scenario when we want to introduce a delay in execution of a subsequent program. Before we move on further to understand the working of delay in Java, let’s understand some practical scenario in which we would need a delay in execution. As soon as the application is loaded and the user logged in, we want to fetch the current location of the user. We are aware that calling certain API like Google Maps API would take at

Read more

Java Reference Variable

We often are stuck at discussion about Objects and their references, it is known fact that unlike C or C++, java doesn’t allows variable access using pointers, well why it does not allows is itself a whole topic which you can read here. Today we will discuss about what all types can be given to java variables or objects. Before moving on to that concept let’s have a look at what do we mean by Reference Variable? Java Reference Variable

Read more
1 2 3 4 5 20