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

The value of x² – 2yx + y² when x = 1, y = 2 is
[tex]prove that\ \textless \ br /\ \textgreater \ \frac { \tan \theta + \sec \theta - 1 } { \tan \theta - \sec \theta + 1 } = \frac { 1 + \sin \theta } { \cos
What is the main idea presented in the passage? tattoos can cause infections through dirty needles. The safety of tattoo inks has not been studied enough. Getti
What is the meaning of issued , candidates and invigilators?​
please help me asap, pleaseee :/ ty ty :D
The value of x² – 2yx + y² when x = 1, y = 2 is
algorithm to find the difference between two numbers second number is greater than first Plzzz solve this problem ​
Fill in the blanks to solve this equation
Complete the equation for photosynthesis. + water + oxygen In light-dependent reactions, light energy is absorbed and converted into chemical energy in the fo
magnesium carbonate and sulphuric acid react to form​