Problem Simple1


Problem Statement

The square length of a string is the square of the number of characters in the string. The square length of "hello" is 25, the square length of "a" is 1, and the square length of "apple sauce" is 121.

Given a string, write a function that returns the string's square length.

Definition

Prototype

public class SquareLength { public int length(String str) { // fill in code here } }

Constraints

Examples

(quote for clarity, they're not part of the string)
  1.   "hello"
    
    Returns:  25
    
    From above

  2.     
    
      "apple sauce"
    
    Returns: 121
    

  3.    
      ""
    
    Returns:0
    

    The empty string has zero length.

  4. 
      "dorothy the dinosaur"
    
    Returns: 400
    

Owen L. Astrachan
Last modified: Wed Jul 23 11:10:49 EDT 2003