java programs
- 02 August
How to find length of string in java without using length() method
One of the interview question is “How to find length of string in java without using length() method.” There are many ways to find length of String. Some of them are : Using toCharArray is simplest solution. Using toCharArray Logic Convert string to char array using toCharArray method Iterate over char array and incrementing length […]
- 01 August
Java program to check Armstrong number
Armstrong number is a 3 digit number which is equal to sum of cube of its digits. For example: 371,153 In this post, we will see how to check for Armstrong number in java. [crayon-6767cb0ed22e3593102509/] When you run above program, you will get following output. [crayon-6767cb0ed22e8520532802/] Please go through Frequently asked java interview Programs for more such […]
- 01 August
Java program to reverse a String
In this post, we will see java program to reverse a String. There are many ways to do reverse a String in java, some of them are: Using for loop Declare empty String reverse. This will contain our final reversed string. Iterate over array using for loop from last index to 0th index Add character […]
- 01 August
How to swap two numbers without using temporary variables in java
In this post, we will see how to swap two numbers without using temporary variables. There are three ways to do it. Java program: [crayon-6767cb0ed24a7296497429/] When you run above program, you will get following output: [crayon-6767cb0ed24aa508375641/] Third way is fastest of all. Please go through Interview programs in java  for more such programs.
- 10 July
How to find prime factors of a number in java
In this post, we will see how to find prime factors of a number in java. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The prime factors of a number are all of the prime numbers that will exactly divide the given number. […]
- 09 July
java program to check prime number
This is easy question. It may not be asked you directly, but you can use this program to create many other complex program. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Program logic: If any number which is not divisible by any other […]
- 09 July
Palindrome program in java
In this article, we will see how to implement palindrome program in java. A palindrome is a word, phrase, number, or other sequence of symbols or elements that reads the same forward or reversed. For example: 12121 is palindrome as it reads same forward or reversed. madam is also a palindrome . This is very […]