1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
pantera1 [17]
3 years ago
13

[Java] Using the comparable interface

Computers and Technology
1 answer:
nadezda [96]3 years ago
7 0

Answer:

Check the explanation

Explanation:

public class Person implements Comparable<Person> {

   private String name;

   public Person(String name) {

       this.name = name;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this. name = name;

   }

   Override

   public int compareTo(Person o) {

       return name.compareTo(o.name);

   }

}

Person 1 ester..) aua .

import java.util.Scanner;

public class PersonTester {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       Person[] people = new Person[10];

       for (int i = 0; i < people.length; i++) {

           System.out.print("Enter name of person " + (i+1) + ": ");

           people[i] = new Person(in.nextLine());

       }

       Person first = people[0], last = people[0];

       for (int i = 0; i < people.length; i++) {

           if (people[i].compareTo(first) < 0) first = people[i];

           if (people[i].compareTo(last) > 0) last = people[i];

       }

       System.out.println("First person is " + first.getName());

       System.out.println("Last person is " + last.getName());

       in.close();

   }

}

You might be interested in
__________ is a term used to indicate any unwanted event that takes place outside normal daily security operations. This type of
Delvig [45]
The answer is “a security event”
6 0
3 years ago
If a node has a wireless connection to the internet, does that node have to be mobile
Marizza181 [45]
No it does not . answers
8 0
3 years ago
How can you use the Address Book to address an email message? Use the drop-down menus to complete the sentences. 1. Type an emai
Delvig [45]

Answer:

1. AutoCorrect

2. Address book

Explanation:

stan bts ?

5 0
3 years ago
Read 2 more answers
Answer for a, b, and c
Darya [45]

The answer is a. im pretty positive but if im wrong super sorry

5 0
3 years ago
1 Which one of the following is a transmission
ElenaW [278]

Answer:

d

Explanation:

All of the above can be means by which signals or information is transferred.

5 0
2 years ago
Other questions:
  • To ease giving access to network resources for employees, you decide there must be an easier way than granting users individual
    9·1 answer
  • You are building a gaming computer and you want to install a dedicated graphics card that has a fast GPU and 1GB of memory onboa
    6·1 answer
  • 4. UPS stands for Uninterrupted Power Supply . (Yes /no
    11·1 answer
  • Creating a Venn diagram takes specialized computer software.
    15·2 answers
  • KAPWING Video Editing Software allows you to use existing You Tube Videos in your design.
    8·1 answer
  • Input 3 positive integers from the terminal, determine if tlrey are valid sides of a triangle. If the sides do form a valid tria
    6·1 answer
  • What is not one of the top health concerns in the United States?physical activitymental healthtobacco useaccess to education
    8·1 answer
  • The full meaning of UNIVAC and ENIAC​
    5·2 answers
  • Write a Dice Game program that generates two random dice values between 1 and 6 for you, and 2 for the computer. You get to roll
    5·1 answer
  • Write the function definition for a function called list_total that accepts a list of integers
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!