สอนเขียนโค้ดเปลี่ยนตัวพิมพ์เล็ก เป็นตัวพิมพ์ใหญ่ Java โดยแนะนำให้ใช้คำสั่ง toUpperCase โดยคำสั่งนี้จะแปลงตัวพิมพ์เล็กของข้อมูลชนิด String และคืนค่าข้อมูลเป็นตัวพิมพ์ใหญ่ สามารถเขียนโปรแกรมได้ดังนี้
ตัวอย่าง เปลี่ยนตัวพิมพ์เล็ก เป็นตัวพิมพ์ใหญ่ Java
class Test {  
    public static void main(String args[]){
        String fruit = "apple";
        System.out.println( fruit );
        System.out.print( "ใช้ toUpperCase เปลี่ยนเป็นตัวพิมพ์ใหญ่ "+fruit.toUpperCase() );
    }
}ผลลัพธ์
apple
ใช้ toUpperCase เปลี่ยนเป็นตัวพิมพ์ใหญ่ APPLE