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

I am have trouble with these x-intercepts. Please help me.​
Which of these is the quadratic parent function?
Please answer this correctly
If pentagon OPQRS is dilated by a scale factor of seven over four from the origin to create O'P'Q'R'S', what is the ordered pair of point Q'? If O negative 1,
A 4% peroxide solution is mixed with a 10% peroxide solution, resulting in 100 L of an 8% solution. The table shows the amount of each solution used in the mixt
How many passwords can be formed using six numbers if the first and last number cannot be zero?
Tes vacances sont pendant quelle saison? Quel temps fait-il? Et qu'est-ce que tu fais?
Richard ordered a coffee table that was a regular pentagon. Find the measure of an exterior angle of the table. (JUSTIFY)
Explain how Co2 is able to control fires?[tex]co2[/tex]​
Can you describe the situations when Greek prefixes are used?