kruthibhogaraju374
kruthibhogaraju374 kruthibhogaraju374
  • 23-02-2021
  • Computers and Technology
contestada

Write a method that returns a String that is just the first and last character of the given string Your return value should be only two characters long. You can assume that the given string will not be empty.​

Respuesta :

MrRoyal
MrRoyal MrRoyal
  • 28-02-2021

Answer:

The method in Java is as follows:

public static String returnlen(String input){

   String output = ""+input.charAt(0)+input.charAt(input.length()-1);

   return output;

}

Explanation:

This defines the method

public static String returnlen(String input){

This concatenates the first and the last character of the input string

   String output = ""+input.charAt(0)+input.charAt(input.length()-1);

This returns the concatenated string

   return output;

}

Answer Link

Otras preguntas

Why did the Egyptians build pyramids? A. to serve as homes for the Egyptian gods B. to be offerings to Horus, patron deity of the king C. to commemorate the joi
what sea touches Hong Kong
The sum if three consecutive even numbers is 78 What is the smallest of the three numbers ?
New Orleans—Jacksonville is a megalopolis. A. True B. False
what is 16=10/3a equal
Jeremy is 5 years younger than his older sister. His older sister is 9 years older than his younger sister. The total of their ages is 49. Write and solve an eq
Use ramadan in a sentence
A group of hens laid the same number of eggs each day for a week. Kelly collected the eggs for six days. Write an expression to show the number of eggs Kelly di
Who was Akbar and what is he well known for
what is the main elements in a plastic cup