Answer the question
In order to leave comments, you need to log in
What type of variable to choose for car records?
Hey!
It is necessary to make records about the cars: number, make, name of the owner, date of the last repair (dd.mm.yy), day by which the car should be repaired (dd.mm.yy) and subsequently sort them. What type of variables is this (that multiple "records" refer to one)?
Answer the question
In order to leave comments, you need to log in
https://habr.com/post/274811/
https://habr.com/post/274905/
https://o7planning.org/ru/11571/data-types-in-java...
Hello!
1) All the data types you have specified, except date, are of type String. Anything related to dates the Date class (as an option)
2) Of course, I don't know what exactly you are trying to implement to offer a good solution, but you can for example create a simple Car class (pojo) with the types of variables you need. For example,
public class Car {
private String carNumber, carModel, carOwner;
private Date lastRepairDate, repairedDate;
// Constructors
public Car() {}
public Car(String carNumber, String carModel, String carOwner, Date lastRepairDate, Date repairedDate) {
this.carNumber = carNumber;
this.carModel = carModel;
this.carOwner = carOwner;
this.lastRepairDate = lastRepairDate;
this.repairedDate = repairedDate;
}
// Getters & Setters
// toString()
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question