Issues With length() And Multiples Of 3

376 views Asked by At

If you get the length of a String using length(), the String always being multiples of 3 (in my case: "1.02.03.04.05.06.07.0 etc.").
Each 3 characters representing a letter, with .1 indicating a capital letter.

How do you use the length to find how many sequences of three there are in the String, for each instance of said String (each time being another multiple of 3)?

Edit:

Yes to Burrito's question, I am looking to find the number of 3 character blocks in each unique String.

1

There are 1 answers

2
user3337714 On BEST ANSWER

It's pretty simple. Next time please show the working of your code.

public int findMultiplesOf3(String value)
{
    return (value.length()/3);
}

Edit


Any length of the string which is less than 3 or not divisible by 3, the return value will only be a whole number. (For Ex 22/3 = 7.333 But the return value would be 7) Since we are returning an int (integer) value in the function header.