Respuesta :
Answer:
Explanation:
The following code is written in the Java programming language. It is a function called howBig that takes in a String as a parameter and returns an int. The function grabs the string and then detects the size of the String (number of Characters it has) and then places that number into an Integer variable called wordSize. Then it returns the variable wordSize.
public static int howBig (String myWord) {
int wordSize = myWord.length();
return wordSize;
}
Following are the Program to the given question:
Program Explanation:
- Defining a class "Main".
- Inside a class, a method "Length" is defined that takes string variable "s" as the parameter.
- Inside the method, a conditional statement is defined that checks length of the string value and prints its value.
- In the next step, the main method is declared that calls the length method, and print its return value.
Program:
public class Main //defining a class Main
{
public static int Length(String s)//defining a method getLength that takes String parameters
{
if(s==null)//defining if block that check s parameter value equal to null
{
return 0;//return 0
}
else //defining else block
{
return s.length();//using return keyword that return length of String
}
}
public static void main(String[] args) //defining a main method
{
System.out.println(Length(null));//calling method and print its value
System.out.println(Length("abcd"));//calling method and print its value
}
}
Output:
Please find the attached file.
Learn more:
brainly.com/question/19737952
![Ver imagen codiepienagoya](https://us-static.z-dn.net/files/de6/c49e75f1ba14c66ef03840c4c080e9c9.jpg)