id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > dec1_2017_APSLHL_countMatches
prev  |  next  |  chance

Write a method that accepts two input parameter strings. The first string will be equal in length to the second string or it will be shorter than the second string. Return how many characters match in the same position in both strings. For example, "two" and "twenty" have two matches since the same characters appear in both of the first two spaces. In the case of "abcde" and "bcdea", there are zero matches because none of the characters match in the same position. The only string methods you are allowed to use are .length, .substring, .charAt, and .equals.


dec1_2017_APSLHL_countMatches("car", "bar") → 2
dec1_2017_APSLHL_countMatches("jump", "jeep") → 2
dec1_2017_APSLHL_countMatches("summer", "winter and spring") → 2

...Save, Compile, Run (ctrl-enter)

public int dec1_2017_APSLHL_countMatches(String str1, String str2) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 270

Copyright Nick Parlante 2017 - privacy