Question: What you need to do: Write and test the method public static String capitalize (String str) which takes a string argument and returns a

What you need to do: Write and test the method public static


What you need to do: Write and test the method public static String capitalize (String str) which takes a string argument and returns a new String consisting of str, with the first character in uppercase and all the remaining characters in lowercase. Non-letter characters are unaffected. Here are some examples: str "bobby" "ILENE" "YOU-tubER" "133t haXXor" "3-Point shot" value returned by capitalize (str) "Bobby" "Ilene" "You-tuber" "L33t haxxor" "3-point shot" Once again, this method is somewhat easier to write if you use the substring method, but can be accomplished (a bit more awkwardly, I'll admit) by using a combination of a for loop, the toCharArray, charAt, toUpperCase, toLowerCase, and String constructor methods.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the implementation of the capitalize method in Java that capitalizes the first character of a string and converts the remaining characters to lo... 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

Document Format (2 attachments)

PDF file Icon

661e87dacd89d_880229.pdf

180 KBs PDF File

Word file Icon

661e87dacd89d_880229.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!