WebString firstLetter = str.substring(0,1); //Take first letter as new string, // this done with help of substring method of String class. String firstLetterCapital = firstLetter.toUpperCase(); String strExcludeFirstLetter = str.substring(1, str.length()); // Final string will be firstLetterCapital followed by strExceptFirstLetter. WebExample 1: Java program to make the first letter of a String capital. class Main { public static void main(String [] args) { // create a string String name = "programiz"; // create …
Java - How to capitalize the first letter of a String
Web19 jul. 2009 · // This method capitalizes first character of a String and make rest of the characters lowercase System.out.println ("wordStr = " + wordStr ); } } Output : This Is … Web15 apr. 2024 · package org.websparrow; import java.util.function.Supplier; public class CapitalizeFirstLetter { public static void main (String [] args) { final String cityName1 = capitalizeFirstLetter ("varanasi"); System.out.println (cityName1); // Varanasi final String cityName2 = capitalizeFirstLetter ("VARANASI"); System.out.println (cityName2); // … tmi business solutions
How to Capitalize the First Letter in a String in JavaScript
Web11 apr. 2024 · To capitalize the first letter of each word in JavaScript, you need to split the sentence or paragraph into an array of words using the split () method. Now you can loop through this array and convert the first letter of every word to uppercase. Finally, you can again convert the array into a string using the join () method on this array. Web22 nov. 2024 · To capitalize the first letter of each word in a string in JavaScript: Split the string into an array of words with .split (''). Iterate over the words array with .map (). For each word,... Web29 jan. 2024 · In this section, we will show you how to capitalize the first letter of a String. In Java, we can use str.substring (0, 1).toUpperCase () + str.substring (1) to make the first letter of a String as a capital letter (uppercase letter) String str = "java"; String cap = str .substring ( 0, 1 ).toUpperCase () + str .substring ( 1 ); //cap = "Java" tmi cable tray supplier