- #1
ProPatto16
- 326
- 0
So this should be simple. but i don't know why it isn't working.
so, I have one class called OdometerBuilder with a method in it. (not a main)
inside that method is like 40 lines of code. I am required to take out that code and make it into a separate class and method, done that. Now i need to call that code from that method, back into the method in OdometerBuilder. NOTE: before i took out the code it all worked perfectly so i know the code is right. just can't seem to call it properly
as i understand, to call a method from another class you first create an instance of that class
Odometer odometerSetter = new Odometer();
odometerSetter is the object name, and Odometer is the class I am calling the method from. That line works fine.
then when calling the method the line is
odometerSetter.setOdometer();
the method in the Odometer class i want is called setOdometer.
however, in odometerBuilder i get an error saying
<package odometerSetter does not exist>
idientifier expected
NOTE: The line odometerSetter.setOdometer(); is INSIDE a method in OdometerBuilder. is that a problem? (the creation of the instance is NOT in any method)
I can post the code if needed, can condense the problem area to probably 100 lines, but someone will need to tell me how to use the code tags in here.
Thanks for any help!
so, I have one class called OdometerBuilder with a method in it. (not a main)
inside that method is like 40 lines of code. I am required to take out that code and make it into a separate class and method, done that. Now i need to call that code from that method, back into the method in OdometerBuilder. NOTE: before i took out the code it all worked perfectly so i know the code is right. just can't seem to call it properly
as i understand, to call a method from another class you first create an instance of that class
Odometer odometerSetter = new Odometer();
odometerSetter is the object name, and Odometer is the class I am calling the method from. That line works fine.
then when calling the method the line is
odometerSetter.setOdometer();
the method in the Odometer class i want is called setOdometer.
however, in odometerBuilder i get an error saying
<package odometerSetter does not exist>
idientifier expected
NOTE: The line odometerSetter.setOdometer(); is INSIDE a method in OdometerBuilder. is that a problem? (the creation of the instance is NOT in any method)
I can post the code if needed, can condense the problem area to probably 100 lines, but someone will need to tell me how to use the code tags in here.
Thanks for any help!