How can I add an object into a set in Java? -
I'm writing some junket test for a bus stop but try to create an object to use through tests Having trouble doing: My problem is that the test will not compile because Eclipse says "new set ()" can not be done immediately, my intention is to 'set' RTA to 'set' To add so that 'stop' can be made without compilation errors, but I am stumped on how to do it. I tried to like it: But Eclipse gave me another error about not having an identifier after 'add'. What would be the best way to contact this? Edit: I have it now: Change it Try the following: to < / P> To add element to the set, Call> add needs to call call instances and replace it with the to Public Class Rococats {BasRout RTE = New Bus Route ("250"); Set up & lt; BusRoute & gt; Set = new set & lt; BusRoute & gt; (); Bus Stop Stop = New Bus Stop (00000, "Staples Center", 90.0, 90.0, Set); ...}
public class rostastes {bus route = new bus route ("250"); Set up & lt; BusRoute & gt; Set = new set & lt; BusRoute & gt; (); Set.add (BusRout RTA); Bus Stop Stop = New Bus Stop (00000, "Staples Center", 90.0, 90.0, Set); ...}
Prevent Public Squares (BusRout RTE = New Bus Route ("250"); Set & lt; BusRoute & gt; ; Set = NewHashet & lt; BusRoute & gt; (); set.add (RTE); Bus Stop Stop = New Bus Stop (00000, "Staples Center", 90.0, 90.0, Set); ...}
set is an interface that can not do this. There is a need to create and create
hashets such as the implementation set.
set BusRoute> Set = New Set BusRoute & gt; ()
set
BusRoute example:
rts.add (BusRoute rte);
set.add (rte);
Comments
Post a Comment