Java program to make the first letter of a String capital Output In the example, we have converted the first letter of the string name to upper case. Example 2: Convert every word of a String to uppercase Output Here, we have created a string named message we converted the string into a char array we access every element of… Continue reading Capitalize first character of each word
Category: 5. Strings
Create random strings
Java program to generate a random string Output In the above example, we have first created a string containing all the alphabets. Next, we have generated a random index number using the nextInt() method of the Random class. Using the random index number, we have generated the random character from the string alphabet. We then used the StringBuilder class to append… Continue reading Create random strings
Check if a String is Numeric
Check if a string is numeric Output In the above program, we have a String named string that contains the string to be checked. We also have a boolean value numeric which stores if the final result is numeric or not. To check if the string contains numbers only, in the try block, we use Double‘s parseDouble() method to convert the string to a Double. If it… Continue reading Check if a String is Numeric