Question: Use the compareTo method to write code that reads two names from the console and prints the one that comes first in alphabetical order. For

Use the compareTo method to write code that reads two names from the console and prints the one that comes first in alphabetical order. For example, the program’s output might look like the following:

Type a name: Tyler Durden

Type a name: Marla Singer

Marla Singer goes before Tyler Durden

Step by Step Solution

3.47 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Code that reads two names from the console and prints the one that comes first in alphabetical ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!