Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:26:36+00:00 2026-05-29T06:26:36+00:00

How should I compare two characters of two CharSequence s? These are my two

  • 0

How should I compare two characters of two CharSequences?

These are my two CharSequences:

CharSequence name1 = fname.getText();
CharSequence name2 = sname.getText();

If I try to compare like this:

if(name1[i] == name2[j])

..it gives me errors.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:26:36+00:00Added an answer on May 29, 2026 at 6:26 am
    String name1 = editText1.getText().toString();
    String name2 = editText2.getText().toString();
    

    To compare particular chars in your String, you can use char charAt(int) method also from String type. Here is example use:

    if(name1.charAt(2) == name2.charAt(0)){
       // Do your stuff
    }
    

    You have to remember that char charAt(int) is zero-based so 0 is first, 1 is second and so on.
    And in this example you can see that I compared two chars just like I would compare integers – with simple ==.

    Comparing whole Strings:

    // This returns true if Strings are equal:
    name1.contentEquals(name2);    
    
    // This returns 0 if Strings are equal:
    name1.compareTo(name2);
    

    To make it case insensitive you can use method from String type toLowerCase() on both Strings.

    name1.equalsIgnoreCase(name2);
    

    or:

    name1.toLowerCase().contentEquals(name2.toLowerCase());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two strings Like 0101000000110110000010010011 and 0101XXXXXXX101100000100100XX it should compare each character and
I would like to compare two array items with php, I think I should
There's the (almost religious) discussion, if you should use LIKE or '=' to compare
I need to compare two strings, containing HTML text. The test should return true
I have two strings. NSString *a=@1_2; NSString *b=@1_3; I want to compare these two
I am looking to compare two exe files. I should ensure that the existing
How do I compare two lists of dict ? The result should be the
How can I compare two NSMutableArray ? if both are same than it should
In my application I should compare two source code files to see if something
Does the C++ Standard say I should be able to compare two default-constructed STL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.