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

what are some countries that have limited and unlimited government?
Which military action led to the start of World War
which effect did the mayflower compact have on american government
Rewrite the expression with parentheses to equal the given value. 3 × 4 - 1 + 2 Value: 11
Make a ten or hundred to add mentally 339+123
What is the function of transition words? a. to introduce formal text b. to join together phrases within a clause c. to move the reader smoothly from one poi
Which text is valuable for gaining context about a historical event but is unreliable as "evidence"?
Where was the most well-known ziggurat located in Sumer? a. Umma b. Ur c. Kish d. Lagash
calculate the mass of a gas with a density of 0.0065 g/cm3 and volume of 260 cm3
Emma is doing a laboratory experiment to separate components of crude oil. She decides to use a technique that will separate the components based on their boili