I have multiple classes of the same package and need to access some variables in different classes. How would I access carName from MenuDisplay in the Car class? feels like I'm almost there but just can't figure it out. Thanks
package carrentaltester;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class MenuDisplay {
public static void displayCarList() {
String CSVfileName = "CarList.csv";
int counter = 0;
try { //open and read the CSV file
File file = new File(CSVfileName);
Scanner input = new Scanner(file);
System.out.format("%-8s%-18s%-10s%-16s%-16s%-16s\n",
"Car No.", "Car Name", "Seats", "Transmission", "Car Type",
"Rate/Day($");
System.out.format("%-8s%-18s%-10s%-16s%-16s%-16s\n", "-------",
"-------", "----- ", "------------", "---------",
"--------");
while (input.hasNextLine()) {
String line = input.nextLine();
counter++;
String fields[] = line.split(",");
String carNumber = fields[0];
String carName = fields[1];
String seats = fields[2];
String transmission = fields[3];
String carType = fields[4];
String ratePerDay = fields[5];
System.out.format("%-8s%-18s%-10s%-16s%-16s%-16s\n",
carNumber, carName, seats, transmission, carType,
ratePerDay);
}
package carrentaltester;
public class Car {
double carRate;
String carName;
MenuDisplay carInfo = new MenuDisplay();
}