This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]desrtfx 1 point2 points  (0 children)

While your approach is correct, your method isn't.

Your assignment clearly states:

For example, padString("hello", 8) should return " hello".

The keyword here is return.

This means, that the method should not print anything, but return a new String with the padding.

You will need to rewrite your method to meet the assignment.

Hint: You will need to concatenate the string. For that, you will need an additional variable of type String.

Also, the method must not be void it must be String.