View Single Post
  #6   Spotlight this post!  
Unread 26-06-2012, 20:51
jhellr13 jhellr13 is offline
Registered User
FRC #4272
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: US
Posts: 187
jhellr13 is an unknown quantity at this point
Re: Code Check Please!

Quote:
Originally Posted by WizenedEE View Post
I think with the timers, you have to define them outside of the loop or else they'll get recreated each time and lose their value.

Like:
Code:
Timer timer1 = new Timer();
while (...) {
  // use timer1
}
not
Code:
while(...) {
  Timer timer1 = new Timer();
  // use timer1
}
In c++ you could make it static, but that doesn't exist in Java:
Code:
while(...) {
  static Timer timer1 = new Timer();
  // use timer1
}
yeah, that might be a problem. Thanks
Reply With Quote