Computers and Technology, 05.05.2020 14:59 Devan6264
[Java] Using the comparable interface
The problem I'm doing is this:
Supply a class Person that implements the Comparable interface. Compare persons by their names. Ask the user to input ten names and generate ten Person objects. Using the compareTo method, determine the first and last person among them and print them.
I have created an ArrayList of the person object that stores the 10 names, but now I'm confused how to use the compareTo() method in the person class. Maybe I'm just confused by the part where it says to determine the first and the last person among them, mainly because that doesn't seem like something you would need to compare. Unless I'm supposed to iterate through the arrayList and compare the elements of the arrayList?
I have the following code for the compareTo() method:
public int compareTo(Object temp)
{
Person other = (Person) temp;
if (this. getName().equals(other. getName()))
{
return this. getName().compareTo(other. getName());
}
return 0;
}
Answers: 1
Computers and Technology, 24.06.2019 14:00
Text or graphics that print at the bottom of every page are called footings footers headers headings
Answers: 1
Computers and Technology, 24.06.2019 17:40
File i/o activity objective: the objective of this activity is to practice working with text files in c#. for this activity, you may do all code in the main class. instructions: create an app that will read integers from an input file name numbers.txt that will consist of one integer per record. example: 4 8 25 101 determine which numbers are even and which are odd. write the even numbers to a file named even.txt and the odd numbers to a file named odd.txt.
Answers: 3
Computers and Technology, 24.06.2019 18:00
Hacer un algoritmo que me permita ingresar el nombre de una parcela de terreno y muestre junto al mensaje “tipo de suelos: suelos fumíferos, ¡excelente!
Answers: 1
Computers and Technology, 24.06.2019 19:20
Which command suppresses the visibility of a particular row or column in a worksheet?
Answers: 1
[Java] Using the comparable interface
The problem I'm doing is this:
Supply a clas...
The problem I'm doing is this:
Supply a clas...
Physics, 15.10.2021 03:00
Mathematics, 15.10.2021 03:00
Computers and Technology, 15.10.2021 03:00
Mathematics, 15.10.2021 03:10
Chemistry, 15.10.2021 03:10
Mathematics, 15.10.2021 03:10
Chemistry, 15.10.2021 03:10
History, 15.10.2021 03:10
Mathematics, 15.10.2021 03:10
Mathematics, 15.10.2021 03:10
English, 15.10.2021 03:10