JAVA EXAMPLE PROGRAMS

JAVA EXAMPLE PROGRAMS

Publish Your Article Here

How to change case of a string characters in Java?


Description:

Below example shows how to convert the case of a given string. toUpperCase() method converts all string characters to upper case. toLowerCase() method converts all string characters to lower case.


Code:
package com.myjava.string;

public class MyStringCase {
    public static void main(String a[]){
        String str = "Change My Case";
        System.out.println("Upper Case: "+str.toUpperCase());
        System.out.println("Lower Case: "+str.toLowerCase());
    }
}

Example Output

Upper Case: CHANGE MY CASE
Lower Case: change my case

Other String Function Examples

Knowledge Centre
What is adapter class?
An adapter class provides the default implementation of all methods in an event listener interface. Adapter classes are very useful when you want to process only few of the events that are handled by a particular event listener interface. You can define a new class by extending one of the adapter classes and implement only those events relevant to you.
Famous Quotations
Before you go and criticize the younger generation, just remember who raised them.
-- Unknown Author

About Author

Most Visited Pages

Other Interesting Sites

Reference: Java™ Platform Standard Ed. 7 - API Specification | Java is registered trademark of Oracle.
Privacy Policy | Copyright © 2017 by Nataraja Gootooru. All Rights Reserved.