|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Access Classes from different file
Does anyone know how to access java classes from a different file? We have always used only one file for all code but now it's so big so I was wondering if there is any way (I'm sure there is some way but idk) to do that.
Like for "User Messages", we made a class "writeUM". Quote:
Thanks. . |
|
#2
|
|||
|
|||
|
Re: Access Classes from different file
You can do that quite easily in fact.
package WriteMessage.*; Code:
public class WriteMessage{
public void writeUM(int line, String Message) {
//lots of code
}
}
Code:
import edu.wpi.first.wpilibj.*;
import WriteMessage.*;
public class RobotFile{
///when you want to access you method
WriteMessage.writeUM(5,"Hello World");
}
|
|
#3
|
||||
|
||||
|
Re: Access Classes from different file
Neal-
Quick question. Do you mean accessing the class or method outside the file? Because it seems your asking if you can access the method outside the file. If you want to access the class, simply add the import to the top of the file. If you want to access the method, you might have to look towards static methods. P.S. I might be completely wrong, if so correct me. buildmaster, I attempted to run your code... Its a no go, I think because method must be static. |
|
#4
|
|||
|
|||
|
Re: Access Classes from different file
IDK what you mean and what I meant by class or method.
Anyways, I figured out what I wanted. And if you failed to run my code, you did something completely wrong as this code is working since forever, I just want the whole "writeUM" thing in a different file. I'm good now. Thanks everyone who tried to help. |
|
#5
|
|||
|
|||
|
Re: Access Classes from different file
I actually figured out what I wanted to do. It's basically what you wrote but I made it easier and different.
Thanks though. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Different approach from a rookie player | feliks_rosenber | Rules/Strategy | 12 | 15-01-2007 15:59 |
| What information can we access from the camera? | Total Meltdown | Programming | 37 | 01-02-2006 11:24 |
| What information can we access from the camera? | Total Meltdown | Programming | 13 | 08-01-2006 13:50 |
| Combining multiple objects in different files into the same scene and file? | DinkyDogg | 3D Animation and Competition | 8 | 19-02-2005 19:14 |
| Good book to learn MS Access from? | Elgin Clock | Math and Science | 2 | 05-10-2004 20:20 |