Need help writing a public method!

Hi guys

I’m trying to write a public method that called isValidLength(String s) that returns true if s is the correct length of 6, and otherwise returns false if <6 or >6

Here is what i have so far…What to I need to enter to make the above possible?


No need to make a duplicate topic, its a forum, just patiently wait for a reply.

it seems you need a way to get the length:

furthermore, a if statement to see if the length equals 6, and a else in case the length isn’t 6.

1 Like

I’ve had a look at a few tutorials like this and gets where they’re coming from. However I’m struggling to link this together with true or false.

I know that it needs to be along the lines of…

If isValidLength(String s) == 6
then True
Else False

But i just don’t know how to put this into Java code

where does then come from all of a sudden, look here:

how we can use if/else

1 Like

Thanks, I’ll give this a try

Are you still stuck?

If so what exactly is the problem, making the if/else statement or finding out the length of s?

A bit of both to be honest with you. I know that the length of s should ==6 and nothing else. It’s just the implementation

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.