The original code would have only two ‘private DcMotor’ variables called left wheel and right wheel.
I’m not sure if I need to do a ‘public class ForeArm () {}’ thing before the ‘public class HyperOpMode_Iterative extends OpMode {’. If anyone could help, that would be great.
Consider posting the entire class, and putting the code between the
tags. That will allow you to post everything without taking up a lot of space. It will also allow us to see that line that Android Studio is complaining about, and make recommendations from there.
A 'local' variable is a somewhat ambiguous term, in that it may mean local scope to the method you're trying to use it in, or local scope to the class. The DcMotor variables you've listed above are scoped to the instance of the class, which is also known as a member variable.
To make a 'local' variable, you'd have to declare a DcMotor inside a method. Yet since creating something like a new DcMotor object for every iterative cycle is a bad idea (you'd much rather use the one you've already created), we need the rest of the code to understand what the problem actually is.
Okay as mentioned we need to see all of your code to help you properly, but I am guessing that you mis-typed the name of one of your field variables, and Android Studio, not seeing that, considers it undefined and is asking you to create a local variable.
You definitely do not need to create a new class named ForeArm. Post all of the code and we can help pinpoint the issue.
You appear to have a mangled Servo declaration (no name).
Aside from that, the original problem is not a problem at all.
Because you are only using the DcMotor objects in init(), Android Studio detects that you could optimize your code by declaring them within init(), instead of outside it. This is not necessary, and the hint will go away if you use them elsewhere.
This inspection searches for redundant class fields that can be replaced with local variables. If all local usages of a field are preceded by assignments to that field, the field can be removed and its usages replaced with local variables.