Java Program to find the largest and smallest word in a string.8 Jan 2025 | 3 min read In this program, we need to find the smallest and the largest word present in the string: Hardships often prepare ordinary people for an extraordinary destiny Consider above example in which 'an' is the smallest word and 'extraordinary' is the largest word. One of the approach to find smallest and largest word is to split string into words then, compare length of each word with variables small and large. If length of a word is less than length of small then, store that word in small. If length of a word is greater than length of large then, store that word in large. ALGORITHM
Program:Output: Smallest word: an Largest word: extraordinary Next TopicJava Programs |
In this program, we have to find out the number of nodes present in the circular linked list. We first create the circular linked list, then traverse through the list and increment variable 'count' by 1. Algorithm Define a Node class which represents a node in the...
5 min read
Java Convert String to double We can convert String to double in java using Double.parseDouble() method. Scenario It is generally used if we have to perform mathematical operations on the string that contains double number. Whenever we get data from textfield or textarea, entered data is received as a...
1 min read
It is a problem frequently asked in interviews of top IT companies like Google, Amazon, TCS, HCL, IBM, and 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...
4 min read
We can reverse each word of a string by the help of reverse(), split() and substring() methods. By using reverse() method of StringBuilder class, we can reverse given string. By the help of split("\\s") method, we can get all words in an array. To get...
1 min read
Java String to Date We can convert String to Date in java using parse() method of DateFormat and SimpleDateFormat classes. To learn this concept well, you should visit DateFormat and SimpleDateFormat classes. Java String to Date Example Let's see the simple code to convert String to Date in java. import java.text.SimpleDateFormat; import...
2 min read
Matrix Programs Matrix relates to mathematics that can be defined as a 2-dimensional array in the form of a rectangle which is filled either with numbers or symbols or expressions as its elements. The matrix has a row and column arrangement of its elements. A matrix with...
1 min read
In this program, we will create a circular linked list and insert every new node at the beginning 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, then we...
6 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...
19 min read
In this program, we need to create a singly linked list and count the nodes present in the list. To accomplish this task, traverse through the list using node current which initially points to head. Increment current in such a way that current will point to...
6 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
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