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
Please help. 10 points
pickupchik [31]

Answer:

God Is Good He Will Always Help You He Is Good And Always Good!!

If God Is For Us Who Can Be Against us?? Romans 8:31

Explanation:

6 0
3 years ago
Read 2 more answers
When the program generates or populates reports after getting the data and processinng,it is called
TiliK225 [7]

Answer:

In computing, extract, transform, load (ETL) is the general procedure of copying data from one or more sources into a destination system which represents the data differently from the source(s) or in a different context than the source(s).

Data extraction involves extracting data from homogeneous or heterogeneous sources; data transformation processes data by data cleansing and transforming them into a proper storage format/structure for the purposes of querying and analysis; finally, data loading describes the insertion of data into the final target database such as an operational data store, a data mart, data lake or a data warehouse. Hope this helps! PLEASE GIVEE ME BRAINLIST!!! =)

6 0
3 years ago
An array similar to a phone book has 1000 names arranged as names [0], names[1]....names[999]. Nancy wants to search a name X in
sammy [17]

Answer:

b. The names in the list should be in alphabetical order.

Explanation:

A binary search is an algorithm used for searching for an item in a list or array. The algorithm first sorts the data structure into order and then divides it into halves. If the searched item is less than the middle item in the list, then the algorithm searches for the target in the first half, else, in the second half. This reduces the time complexity of the search.

5 0
3 years ago
Kai recently graduated from college with a dual degree—a Bachelor’s in Game Design and Development and a Bachelor’s in Music. Th
irakobra [83]
Audio designer

Audio designers plan , sound effects, music and pretty much anything that has to do with sound in a video game
6 0
2 years ago
For each of the following memory accesses indicate if it will be a cache hit or miss when carried out in sequence as listed. Als
nika2105 [10]

Answer:

Explanation:

Operation Address Hit? Read Value

Read 0x834 No Unknown

Write 0x836 Yes (not applicable)

Read 0xFFD Yes CO

6 0
3 years ago
Other questions:
  • Write a script named numberlines.py. This script creates a program listing from a source program. This script should: Prompt the
    7·1 answer
  • Que son los sistemas de control con retroalimentacion
    10·1 answer
  • Define a class named ComparableSquare that extends Square (defined above) and implements Comparable. Implement the compareTo met
    7·1 answer
  • Because all the IEEE WLAN features are isolated in the PHY and ____________ layers, practically any LAN application will run on
    11·1 answer
  • C++
    14·1 answer
  • Is social media bringing people together or cause in sepretation?​
    11·2 answers
  • Advantages and disadvantages of java
    10·1 answer
  • Drag the tiles to the boxes to form correct palrs.
    9·1 answer
  • Write a java code to print Multiplication Table Till 20
    14·2 answers
  • Which of the following recommendations should you follow when placing access points to provide wireless access for users within
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!