Java Program to capitalize each word in String7 Jan 2025 | 1 min read We can capitalize each word of a string by the help of split() and substring() methods. By the help of split("\\s") method, we can get all words in an array. To get the first character, we can use substring() or charAt() method. Let's see the example to capitalize each word in a string. File: StringFormatter.java File: TestStringFormatter.java Output: My Name Is Khan I Am Sonoo Jaiswal Next TopicJava Main Method |
Java program to print the following pattern on the console 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Algorithm: STEP 1: START STEP 2: SET n=5. STEP 3: SET i=0. REPEAT STEP 4 to STEP 8 UNTIL i<=n. STEP 4: SET j=0.REPEAT STEP 5 to STEP 6 UNTIL...
1 min read
In this program, we need to check whether given matrices are equal or not. Two matrices are said to be equal if and only if they satisfy the following conditions: Both the matrices should have the same number of rows and columns. Both the matrices should have the...
5 min read
Java Convert Decimal to Binary We can convert decimal to binary in java using Integer.toBinaryString() method or custom logic. Java Decimal to Binary conversion: Integer.toBinaryString() The Integer.toBinaryString() method converts decimal to binary string. The signature of toBinaryString() method is given below: public static String toBinaryString(int decimal) Let's see the simple example...
1 min read
In this program, we will create a doubly linked list then, iterate through the list to find out the minimum and maximum node. We will maintain two variables min and max. Min will hold the minimum value node, and max will hold the maximum value node....
6 min read
In this program, we need to remove the duplicate nodes from the given singly linked list. Original List: List after removing duplicate nodes: In the above list, node 2 is repeated thrice, and node 1 is repeated twice. Node current will point to head, and index will point...
7 min read
Java Convert Timestamp to Date We can convert Timestamp to Date in java using constructor of java.util.Date class. The constructor of Date class receives long value as an argument. So, you need to convert Timestamp object into long value using getTime() method of java.sql.Timestamp class. Let's see the constructor...
2 min read
In this section, we will learn what is a spy number and also create Java programs to check if the given number is Spy or not. The spy number program is frequently asked in Java coding test. Spy Number A positive integer is called a spy number if...
3 min read
Krishnamurthy number is another special number in Java. A number is said to be Krishnamurthy if the factorial sum of all its digits is equal to that number. Krishnamurthy number is also referred to as a Strong number. Just like Prime and Armstrong numbers, Krishnamurthy number...
3 min read
In this program, we need to check whether all the leaves of the given binary tree are at same level or not. A Node is said to be leaf if it doesn't have any child node. In the below diagram, nodes 4, 5 and 6 are...
5 min read
Java Convert char to int We can convert char to int in java using various ways. If we direct assign char variable to int, it will return ASCII value of given character. If char variable contains int value, we can get the int value by calling Character.getNumericValue(char) method....
1 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