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
9. In Electronic Codebook (ECB): a. The message is broken into independent blocks which are encrypted b. The message is broken i
DaniilM [7]

Answer:

The correct answer is letter "A": The message is broken into independent blocks which are encrypted.

Explanation:

There are five (5) main forms of encryption: <em>Electronic Code Book (ECB), Cipher Block Chaining (CBC), Cipher Feedback (CFB), Output Feedback (OFB), and Output Feedback (OFB)</em>. Electronic Code Book (ECB) is the simplest of all of them. Using this method to encrypt information implies dividing a message into two parts to encrypt each block independently. ECB does not hide patterns effectively because the blocks are encrypted using identical plaintexts.

8 0
3 years ago
This is going to get taken down but I dont care add me on discord cause ima bored<br> -Red-#9847
Alex777 [14]

Answer:

I WILL

Explanation:

6 0
3 years ago
How to make the heart symbol in photoshop
sveta [45]
Click the font drop-down box in the tool settings bar. Select "Arial." 6. Press "Alt-3" using your keyboard number pad's "3" key to insert the heart symbol<span>.</span>
3 0
3 years ago
Read 2 more answers
Technical colleges offer certification in audio engineering through programs that are normally from 2 to 6 months long.
Murrr4er [49]

Answer:

False

Explanation:

i said so

8 0
3 years ago
Un usuario desea conocer de manera descriptiva ,como se lleva a cabo el proceso de solicitud de transferencia monetaria en una p
Rus_ich [418]

Answer:

Research My Friend Use a Translator Promise!!

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which cloud computing service model gives software developers access to multiple operating systems for testing?
    5·1 answer
  • What type of restrictions may be placed on your license?
    7·1 answer
  • List and explain the error in the code
    14·1 answer
  • PLEASE HELP ME ON THIS..............PLEASEEEEEEEEEEEE PLEASEEEEEE<br><br> ITTS EASYYYYYYYY
    12·1 answer
  • Which type of computer operating system would be best for a large corporation?
    7·2 answers
  • Online banking tools allow you to pay bills from your computer. <br> a. True<br> b. False
    5·2 answers
  • In the code segment below, assume that the int variable n has been properly declared and initialized. The code segment is intend
    5·1 answer
  • Write a method named lastIndexOf that accepts an array of integers and an * integer value as its parameters and returns the last
    15·1 answer
  • There are types of templates​
    5·1 answer
  • Prompts what is a row?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!