Forum Stats

  • 3,827,853 Users
  • 2,260,831 Discussions
  • 7,897,398 Comments

Discussions

Collection data output behavior

838385
838385 Member Posts: 1
edited Mar 26, 2016 11:19PM in New To Java

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?

Answers

This discussion has been closed.