Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Make the first letter caps and the rest lowercase in Java
The following is an example −
Example
public class Demo {
public static void main(String[] args) {
String str = "laptop";
System.out.println("Original String = " +str);
// letter one
String strOne = str.substring(0,1).toUpperCase();
// remaining letters
String strTwo = str.substring(1).toLowerCase();
System.out.println("Resultant String = "+strOne + strTwo);
}
}
Output
Original String = laptop Resultant String = Laptop
Advertisements
