Question: 1. Create a new class named StringDemo.java. This class will have a main() method that does the following: a. Instantiates and initializes a String object
1. Create a new class named StringDemo.java. This class will have a main() method that does the following:
a. Instantiates and initializes a String object named myLastName (should be initialize to your last name)
b. That displays in a sentence the length of your last name (using the appropriate String method)
c. Declares an integer named secondLastLetter that is equal to 2 less than the length of your last name.
d. Uses the appropriate String method to display your second-to-last character of your last name (in a complete sentence).
e. Uses the appropriate String method to display your last name all in Upper Case letters.
f. Has an if statement that compares your last name to the string Short, and displays whether or not you have the same last name as your professor.
g. Has an if statement that determines whether your last name contains the character sequence ne. If your last name contains ne a statement should state that your last name (display it) contains the character sequence ne, or it should say that it does not. e.g. Display for the instructor will be: The last name Short does not contain ne
h. Please take notice of the double quotes. Note: Google the Java API to find which method checks for character sequences in a String object.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
