|
Re: JAVA 101 help
When you evaluate door == "t" it is not checking to see if door has that value. It is checking to see if the bits are the same. In the case of a String object, that means "are they pointing at the same place in memory?", not "are they equal in value?" Because the bits are the location where the object's data is stored. With an integer you are dealing with a primitive so the bits are a value and not a memory location. As GeeTwo said, if you use if(door.equals("t")) you will get the comparison you want.
__________________
Thank you Bad Robots for giving me the chance to coach this team.
Rookie All-Star Award: 2003 Buckeye
Engineering Inspiration Award: 2004 Pittsburgh, 2014 Crossroads
Chairman's Award: 2005 Pittsburgh, 2009 Buckeye, 2012 Queen City
Team Spirit Award: 2007 Buckeye, 2015 Queen City
Woodie Flowers Award: 2009 Buckeye
Dean's List Finalists: Phil Aufdencamp (2010), Lindsey Fox (2011), Kyle Torrico (2011), Alix Bernier (2013), Deepthi Thumuluri (2015)
Gracious Professionalism Award: 2013 Buckeye
Innovation in Controls Award: 2015 Pittsburgh
Event Finalists: 2012 CORI, 2016 Buckeye
|