0

I made a program and want to enter previous dates into a linkedList. My code is

package bowlinggame;

import java.util.Date;
import java.util.LinkedList;
import java.util.TreeSet;

public class BowlingGame {   
    
    public static void main(String[] args) 
    {
        TreeSet <String>PlayerNames = new TreeSet<String>();
        PlayerNames.add("Steve");
        PlayerNames.add("James");
        PlayerNames.add("Bob");
        for (Object o : PlayerNames) 
        {
            System.out.println(o);
        }
        LinkedList <Date>SteveDate = new LinkedList<Date>();// Enter the dates here just like scores
        LinkedList <Integer>SteveScore = new LinkedList<Integer>();
        SteveScore.add(205);
        SteveScore.add(240);
        SteveScore.add(189);
        System.out.println("Steve's last score is " + SteveScore.getLast() + " and the last time he played was " + SteveDate);
    }
}
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by JamesCherrill
1

Have a look at the SimpleDateFormat class. You will find it has methods to convert (parse) Strings in various formats into Dates that you can add to your list.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.