Java Program to replace the spaces of a string with a specific character8 Jan 2025 | 1 min read In this program, we need to replace all the spaces present in the string with a specific character.
One of the approach to accomplish this is by iterating through the string to find spaces. If spaces are present, then assign specific character in that index. Other approach is to use a built-in function replace function to replace space with a specific character. For programming, follow the algorithm given below: Algorithm
Program:Output: String after replacing spaces with given character: Once-in-a-blue-moon Next TopicJava Programs |
Program to print the elements of an array present on even position In this program, we need to print the element which is present on even position. Even positioned element can be found by traversing the array and incrementing the value of i by 2. In the...
1 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
Java Convert boolean to String We can convert boolean to String in java using String.valueOf(boolean) method. Alternatively, we can use Boolean.toString(boolean) method which also converts boolean into String. 1) String.valueOf() The String.valueOf() method converts boolean to String. The valueOf() is the static method of String class. The signature of...
1 min read
Program to print the largest element in an array In this program, we need to find out the largest element present in the array and display it. This can be accomplished by looping through the array from start to end by comparing max with all the...
2 min read
In this program, we will create a circular linked list and delete a node from the beginning of the list. If the list is empty, print the message "List is empty". If the list is not empty, we will make the head to point to...
6 min read
? Two strings are called anagrams if they contain same set of characters but in different order. "keep ? peek", "Mother In Law - Hitler Woman". File: AnagramString .java import java.util.Arrays; public class AnagramString { static void isAnagram(String str1, String str2) { String s1 = str1.replaceAll("\\s", ""); String s2 = str2.replaceAll("\\s", ""); boolean...
1 min read
In this program, we will create a circular linked list and delete a node from the middle of the list. If the list is empty, display the message "List is empty". If the list is not empty, we will calculate the size of the list...
9 min read
In this section, we will learn automorphic numbers with examples and also create Java programs that check whether the number is automorphic or not. What is an automorphic number? A number is called an automorphic number if and only if the square of the given number ends with...
3 min read
In this program, we need to create a singly linked list and display the list in reverse order. Original List Reversed List One of the approaches to solving this problem is to reach the end the of the list and display the nodes from tail to head recursively. Algorithm Create...
5 min read
It is a very interesting problem frequently asked in interviews of top IT companies like Google, Amazon, TCS, Accenture, etc. By solving the problem, one wants to check the logical ability, critical thinking, and problem-solving skill of the interviewee. So, in this section, we are going...
3 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