Skip to Main Content

Collection data output behavior

838385Mar 26 2016 — edited Mar 26 2016

Hi, I am working on a sumo project. I am using TraCI 4J to control the simulation. I am stuck in a simple problem:

for (int i = 0; i < 37260; i++) {

     Collection<Vehicle> vehicles = conn.getVehicleRepository().getAll().values();

     Iterator<Vehicle> itr = vehicles.iterator();

     while (itr.hasNext()) {

             Vehicle vehicle = itr.next();

                        if(vehicle.getType()=="typeNS")

                                System.out.println("Found typeNS");

                       if(vehicle.getType()=="typeWE")

                                System.out.println("Found typeWE");

 

 

  System.out.println(vehicle.getType());

    }

}

The last output gives every possible vehicle.getType but the top if statement always get ommitted. There are hundres of typeNS and typeWE but it does not catch that. Any idea? What's the problem here?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Apr 23 2016
Added on Mar 26 2016
1 comment
670 views