Neon Number in Java

Here in this tutorial you will learn how to check a neon number in Java. What is a Neon Number? Neon numbers are those numbers whose sum of the digits when squared is exactly the same as the number itself. For example, the number 9. Now the square of the number, 9 is 81. The sum of the digits in the square, 81 is 8 + 1 = 9, which is equal to the number itself. Hence, the number 9

Read more

Java Random Number Generator

Random numbers may be required for sorts of programming jobs. For example, statistical sampling, computer simulation, cryptography, and other areas where producing random unpredictable results is desirable. Java provides certain ways in which we can generate random numbers. Although, the generated random numbers are pseudo-random, they get the work done mostly. We can generate random numbers in Java using the following two ways. Java Random Number Generator Method 1: lang.Math To generate random numbers, we can use the Math.random() method.

Read more

Difference between Error and Exception in Java

Here in this article you will learn about difference between error and exception in java. In exception hierarchy we need to see where these two classes exist. Throwable Class is the root for the Java Exception Hierarchy. Throwable contains two chain of classes, Exception and Error. Exceptions Errors Mostly because of our programs. These occur because of lack of system resources. Exceptions are recoverable. Errors are not recoverable. Exceptions can be handled using try catch blocks. Errors cannot be handled

Read more

How to Square a Number in Java

We can square a number in Java in no less than two different ways. Let have a look on each method one by one. Method1: Multiplying the Number by Itself To square a number x, we can multiply the number by itself. Y = x * x. Java Program for the above method.

Output: Enter a number: 5 The Square of the number is : 25 Method 2: Using the Math.pow() Function Lets have a look how we can

Read more

Solve Missing Return Statement Error in Java

There are many types of errors that can be encountered while writing a Java Program. The errors can be with the Syntax or the Semantics of the Java program. The Java Community tries hard to avoid these errors at compile time itself, so that a programmer does not have to run the program to encounter the error. Use of generics is one way by which Java provides Type Safety by throwing errors at compile time itself. Solve Missing Return Statement

Read more

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
1 2 3 4 5 6 21