Share on Google+Share on Google+

String comparison example

There are many comparison operators for comparing strings like <, <=, !=, ==, =>, and >.

String comparison example:-

There are many comparison operators for comparing strings like <, <=, !=, ==, =>, and >. Action script  compare strings on the character code value for each character in the string. In the Action script3, every comparison process of characters from left to right. These comparison operators can be used with conditional statements. In the given example, we can use "= =" operator for compare two strings.


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

<s:Application xmlns:fx=""


xmlns:mx="library://" creationComplete="init();">



private function init():void{

var str1:String = "Brijesh";

var str2:String = "brijesh";

myText1.text = "This is first String :" + str1;

myText2.text = "This is second String :" + str2;

if(str1 == str2){

myText3.text = "Yes";



myText3.text = "No";


if("Brijesh" == "Brijesh"){

myText4.text = "Yes";



myText4.text = "No";


if("A" == "a"){

myText5.text = "Yes";



myText5.text = "No";





<s:Panel width="200" height="200" title="String compare" backgroundColor="0x81B5AA">


<mx:Text id="myText1"/>

<mx:Text id="myText2"/>


<mx:Text text="'Brijesh' == 'brijesh'"/>

<mx:Text id="myText3"/>



<mx:Text text="'Brijesh' == 'Brijesh'"/>

<mx:Text id="myText4"/>



<mx:Text text=" 'A' == 'a' "/>

<mx:Text id="myText5"/>






Download this code



Posted on: June 8, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.