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

  • Home
  • SEARCH
  • 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 7690201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:20:30+00:00 2026-05-31T20:20:30+00:00

I have an issue with a string compare problem… lets say: string a =

  • 0

I have an issue with a string compare problem…

lets say: string a = “0123456789ABCDEF” string b = “00CC0G”

how do i loop a java code so i can check string a for match with each letter from string b. While comparing the match, the letter from string b has to go thru the entire loop against string a before deciding if there is a match or not. if a match is found it should check the next letter in string b against string a and so on until the last letter in string b. if no match is found, the function shud exit the loop and return false. otherwise if each letter in string b is a match atleast once with string a, the function shud return true.

Example… the function should return false, because the first 5 letters match but the last one doesnt.

any idea? Thanks

EDIT: what i have so far

public boolean checkVal(String b) {

// b = "00CC0G";

String a = "0123456789ABCDEF";
String toUC = b.toUpperCase();
char[] cArray = toUC.toCharArray();
char[] vArray = a.toCharArray();
int j = 0;
int m = 0;

for (int i = 0; i <=cArray.length(); i++) {
    for (int k = 0; k <= vArray.length(); k++) {
        if (cArray[k] == vArray[i]) {
            j++;
        }
        else {
            m--;
            break; //loop should exit if there is a non match and function should return false
        }
    }
}

if (j > 0)  return true; //string a matched atleast once with string b
if (m < 0)  return false; //string a alteast has one NO MATCH with string b

}

The looping is what getting me confused…

  • 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-31T20:20:31+00:00Added an answer on May 31, 2026 at 8:20 pm

    Spoonfeeding since 2k12.

       public static boolean isValid(String a, String b){
        for(char c : b.toCharArray())
            if(!a.contains(""+c))
                return false;
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can you please help me with this issue the String class does not have
I have got the following issue, my function appends code to a string $string
Possible Duplicate: Evaluate C# string with math operators So lets say I have a
I have an issue how to implement to compare two static arrays, ie. string
i have a issue with programming for android. i have a string like this:
I have been facing issue with sphinx result set for string attribute. Below is
ok so my issue is i have the string '\222\222\223\225' which is stored as
I have defined the following interface: public interface IHaveAProblem { string Issue { get;
I have an issue using the Dynamic Expression API. I cannot seem to compare
I have a problem involving encoding/decoding. I read text from file and compare it

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.