Java Program to count the total number of characters in a string8 Jan 2025 | 1 min read In this program, we need to count the number of characters present in the string: The best of both worlds To count the number of characters present in the string, we will iterate through the string and count the characters. In above example, total numbers of characters present in the string are 19. For programming, follow the algorithm given below: Algorithm
Program:Output: Total number of characters in a string: 19 Next TopicJava Programs |
In this program, we need to count and print the number of elements present in the array. The number of elements present in the array can be found by calculating the length of the array. Length of above array is 5. Hence, the number of elements present...
1 min read
In this program, we will create a circular linked list and insert every new node at the end of the list. If the list is empty, then head and tail will point to the newly added node. If the list is not empty, the newly...
6 min read
12344321 123**321 12****21 1******1 Algorithm: STEP 1: START STEP 2: SET lines=4 STEP 3: DEFINE i, j. STEP 4: SET space=0 STEP 5: SET i=0 STEP 6: REPEAT STEP 7 TO 20 UNTIL i STEP 7: SET j=1 STEP 8: REPEAT STEP 9 UNTIL j <= space. STEP 9: PRINT " " and SET J=J+1 STEP 10: SET...
2 min read
Write a code to check whether one string is a rotation of another? File: RotationString .java public class RotationString { public static boolean checkRotation(String st1, String st2) { if (st1.length() != st2.length()) { return false; } String st3 = st1 + st1; if (st3.contains(st2)) return true; else return false; } public static void main(String[] args) { String str1...
1 min read
In this section, we will learn what is tech number and how can we find tech numbers through a Java program. Tech Number A number is called a tech number if the given number has an even number of digits and the number can be divided exactly into...
3 min read
In this program, we need to check whether a given string is palindrome or not. A string is said to be palindrome if it is the same from both the ends. For e.g. above string is a palindrome because if we try to read it from...
2 min read
In this program, we need to display the lower triangular matrix. Lower Triangular Matrix Lower triangular matrix is a square matrix in which all the elements above the principle diagonal will be zero. To find the lower triangular matrix, a matrix needs to be a square matrix...
4 min read
The Evil number is another special positive whole number in Java that has an even number of 1's in its binary equivalent. Unlike Prime and Armstrong numbers, Evil number is not so popular and asked by the interviewers. The numbers which are not evil are called odious...
3 min read
In this section, we have created a number of Java program to check if a given number is perfect square or not. The perfect square or square number is a positive integer that is square of an integer. In other words, when we multiply two same numbers...
6 min read
Program to print the smallest element in an array In this program, we need to find out the smallest element present in the array. This can be achieved by maintaining a variable min which initially will hold the value of the first element. Loop through the...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India