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: 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); ...}

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:

  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); ...}   

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:

  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.

Change it Try the following:

 set  BusRoute> Set = New Set  BusRoute & gt; ()   

to < / P>

  set  Set = New Hashet  BusRoute>    

To add element to the set, Call> add needs to call call instances and replace it with the BusRoute example:

  rts.add (BusRoute rte);   

to

  set.add (rte);    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -