String toLowerCase and toUppercase methods example


 

String toLowerCase and toUppercase methods example

String class provides methods toUpperCase() and toLowerCase().

String class provides methods toUpperCase() and toLowerCase().

String toUpperCase() and toLowerCase() methods example:-

String class provides methods toUpperCase() and toLowerCase(). Method toUpperCase() convert alphabetical characters in the string to uppercase and method toLowerCase() convert alphabetical characters in the string to  lowercase. We have used these two methods in this example. user can see how to use these methods.

Example:-

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init();">

<fx:Script>

<![CDATA[

private function init():void{

var str1:String = "Rose India";

// for upper case

textcontrol1.text = str1.toUpperCase();

// for lower case

textcontrol2.text = str1.toLowerCase();

}

]]>

</fx:Script>

<s:Panel width="250" height="200" title="String Upper and Lower case example" backgroundColor="0xEEFFEE">

<s:VGroup>

<mx:Text id="textmsg1" text="Upper Case" fontSize="12" fontWeight="bold"/>

<mx:Text id="textcontrol1"/>

<mx:Text id="textmsg2" text="Lower Case" fontSize="12" fontWeight="bold"/>

<mx:Text id="textcontrol2"/>

</s:VGroup>

</s:Panel>

</s:Application>

In this example, we have created a string type variable and initialize a string as "Rose India" and apply both toLowerCase() and toUpperCase() methods on them.

Output:-

0

Download this code

Ads