Question: Write a method called padString that accepts two parameters: a string and an integer representing a length. The method should pad the parameter string with

Write a method called padString that accepts two parameters: a string and an integer representing a length. The method should pad the parameter string with spaces until its length is the given length. For example, padString("hello", 8) should return "hello " . (This sort of method is useful when trying to print output that lines up horizontally.) If the string’s length is already at least as long as the length parameter, your method should return the original string. For example, padString("congratulations", 10) should return "congratulations".

Step by Step Solution

3.35 Rating (167 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public static String padst... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!