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
Technician A says a modern automobile has more than 1 mile of wiring. Technician B says there could be more than 1,000 individua
FinnZ [79.3K]
Both because if you put all of the wires from end to end there is more then one mile of wiring 
7 0
3 years ago
What does the Sort feature do with a database
WARRIOR [948]
Nothing. If you SELECT data from a database, and add an ORDER BY clause, it just affects the ordering of the data that is returned to the user, but the data in the database remains unaltered.
6 0
4 years ago
Which was the first arcade game that was adapted for mobile phones ????
natka813 [3]

The correct answer is Snake.

4 0
3 years ago
Easy Bib and Cite This For Me are examples of online
motikmotik
The answer is:  [A]:  "bibliographic generators" .
____________________________________________________
5 0
3 years ago
How long are most personal vision statements?
ki77a [65]

Answer:

Your personal vision statement guides your life and provides the direction necessary to chart the course of your days and the choices you make about your career, life, and family.Think of your personal vision statement as the light shining in the darkness that illuminates your path through the forest of life.Write in the first person and make statements about the future you hope to achieve. Write the statements as if you are already making them happen in your life. Some experts recommend 50 words or less, but forget word counts and fully articulate the vision that you want for your life and your future.Writing a vision statement is the first step in focusing on your life. It can help put things into perspective—your joy, your accomplishments, your family life, and your contributions.Ask yourself some guiding questions to start yourself off. Be honest. Your answers can help you clearly illustrate your vision.

As you collect information on yourself, take time to formulate your thoughts cohesively into descriptive sentences or paragraphs that summarize single values or characteristics.

8 0
3 years ago
Other questions:
  • ___________ is a mass-produced, copyrighted software that meets the needs of a wide variety of users, not just a single user or
    15·1 answer
  • A cracked tone (reluctor) ring will often cause what type of problem
    13·1 answer
  • Alex's woodworking shop is trying to design a web page with Cascading Style Sheets (CSS). Alex would like create the new design
    11·1 answer
  • Write the reverseO function recursively. This function takes a string and the length of the string as arguments and returns the
    15·2 answers
  • Big data: options:
    8·1 answer
  • 1.  
    15·1 answer
  • A friend is interested in keeping track of information about his album collection. He is not concerned about whether or not the
    11·1 answer
  • 10
    14·2 answers
  • Put these numbers in order from smallest to largest:<br> 1. 00101112<br> 2. 011110<br> 3. 011110112
    12·2 answers
  • 2. Why do you think the order of operations still applies in Java? Give an example to show what could happen if you didn't use o
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!