Q:

write java program to convert the first character in a string to uppercase

belongs to collection: Java String Solved Programs

0

write java program to convert the first character in a string to uppercase

Hint: use charAt() function

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

public class Main {
public static void main(String[] args) {   
 
 //write java program to convert the first character in a string to uppercase
    String s="nerdutella.com";
    String firstChar=Character.toString(s.charAt(0));
    firstChar=firstChar.toUpperCase();
    String newS=firstChar;
    for(int i=1;i<s.length();i++)
    newS=newS+Character.toString(s.charAt(i));
    System.out.println("the string after converting first character to uppercase: "+newS);
   }
}

 

output:

the string after converting first character to uppercase: Nerdutella.com

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java String Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
write java program to print the last character in ... >>
<< Write a Java Program to Count Frequency or Occurra...