
10-04-2014, 06:19
|
 |
Registered User
 FRC #0316 (LuNaTeCs)
Team Role: College Student
|
|
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
|
|
|
Re: Using multiple classes in java to control one pwm
Quote:
Originally Posted by vgdude999
From my (very basic) understanding, non static variables and methods can only be used if an object of their class is created. So, if you kept the talons non static, you would have to actually create an instance of the outputmap.
So,
outputmap x = new outputmap();
Static variables and methods, however, do not require this.
Please correct me if anything I said is horribly wrong 
|
This is correct. Non-static variables belong to a specific instance of a class; each instance has it's own copy. Static variables belong to the class itself; they exist independent of an instance. Before, when the first instance of outputmap was created, it allocated the IO channels that OP was using. If a second instance was attempted, it would be trying to reallocate those IO ports. Since you can only have one instance of a given IO channel, an AllocationException was thrown.
__________________
LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!
FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)
|