Identify the stations between which the distance is shortest - Java Quiz Question


Write a program to identify the stations between which the distance is shortest. The output string should be formatted as shown in the requirements below.

Input (List) Output (String)
[[Kavali-null-06:10-0], [Tettu-06:20-06:25-2], [Ulavapadu-06:50-06:55-10), [Singarayakonda-07:15-07:20-5], [Ongole-08:00-null-15]] The shortest distance is 2km and it is between 'Kavali' and 'Tettu'"
[[Nellore-null-10:00-0], [Ongole-11:30-11:40-30], [Guntur-12:30-12:50-28], [Vijayawada-14:05-14:40-35], [Kakinada-15:20-15:25-15], [Rajahmundry-16:00-16:05-18], [Visakhapatnam-17:35-null-45]] The shortest distance is 15km and it is between 'Vijayawada' and 'Kakinada'
[[Chennai-null-18:00-0], [Gudur-20:00-20:20-100], [Nellore-21:00-21:10-25], [Kavali-21:30-21:35-20], [Ongole-22:30-22:40-40], [Chirala-23:30-23:35-31], [Tenali Junction-00:30-00:35-31], [Vijayawada-01:05-01:35-45], [Hyderabad-03:20-03:50-100], [Karimnagar-05:35-null-60]] The shortest distance is 20km and it is between 'Nellore' and 'Kavali'


import java.util.*;
class ShortestDistance
{
    public static void main(String s[])
    {
        ArrayList<Destination> journey = new ArrayList<Destination>();
        journey.add(new Destination("Chennai", null, "18:00", 0));
        journey.add(new Destination("Gudur", "20:00", "20:20", 100));
        journey.add(new Destination("Nellore", "21:00", "21:10", 25));
        journey.add(new Destination("Kavali", "21:30", "21:35", 20));
        journey.add(new Destination("Ongole", "22:30", "22:40", 40));
        journey.add(new Destination("Chirala", "23:30", "23:35", 31));
        journey.add(new Destination("Tenali Junction", "00:30", "00:35", 31));
        journey.add(new Destination("Vijayawada", "01:05", "01:35", 45));
        journey.add(new Destination("Hyderabad", "03:20", "03:50", 100));
        journey.add(new Destination("Karimnagar", "05:35", null, 60));
        System.out.println(getShortestDistance(journey));

    }


    private static String getShortestDistance(ArrayList<Destination> journey) {
    }
    

}
class Destination {

String cityName;
String arrivalTime;
String depatureTime;
int kiloMeters;

public Destination(String cityName, String arrivalTime, String depatureTime, Integer kiloMeters) {
this.cityName = cityName;
this.arrivalTime = arrivalTime;
this.depatureTime = depatureTime;
this.kiloMeters = kiloMeters;
}

@Override
public String toString() {
return "[" + cityName + "-" + arrivalTime + "-" + depatureTime + "-" + kiloMeters + "]";
}
}