Java Programming Question

Given 2 strings, a and b, return the number of the positions where they
contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3,
since the "xx", "aa" and "az" substring appear in the same place in
strings.

stringMatch("xxcaazz","xxbaaz") -> 3

stringMatch("abc", "abc") -> 2

stringMatch("abc", "axc") -> 0

public int stringMatch(String a, String b)
{
     write code???
}
robdijoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Post the code you've written and we'll help with it. We don't write classwork for people
0
robdijoAuthor Commented:
I do not know where to start.  I have no code.
0
CEHJCommented:
Break down the task into parts, starting with

a. obtain all length 2 substrings from the source string by iteration [and print them out]

(the part in brackets can be removed later)
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

for_yanCommented:


Is this your class assignment ?
0
for_yanCommented:


Determine the minimum of two lengths,

Math.min(s0.length(), s1.length())

initiate the counter int count = 0;
start the loop from 0 to the index of minimumlength-3

make

if(s0.substring(curindex, currentindex+2).eqiuals(s1.substring(curentindex,curindex+2)))count++

when you exit the loop
your counter will have number of matches

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
for_yanCommented:
write the code in this sense - post it we will correct
0
CEHJCommented:
>>write the code

No need - you did it for him. Homework done then...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.