public String firstAndLast(String str) { //declare and create your first char   //declare and create your second char   //return your first and last char as a String      }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 9E
icon
Related questions
Question
100%

public String firstAndLast(String str)

{

//declare and create your first char

 

//declare and create your second char

 

//return your first and last char as a String 

 

 

}

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.
The method signature should be
public String firstAndLast(String str)
Transcribed Image Text: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. The method signature should be public String firstAndLast(String str)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Methods of StringBuilder class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,