This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
I've written a simply stand alone program and now wish to remove the main main method. Is there a java expert in here that can show this using acutal code that compiles?
Details: I've written ReadFileIn that reads comma-delimited, ascii files. However, I now wish to remove the main method and use this program from another class called ReadFileInTestDrive. This is similar to what is done in the book :HeadFirst Java.
You should only have to delete the main function, and I don't see any reason why it should compile. Then in your other class - ReadFileInTestDrive - you'd need to import ReadFileIn, construct an instance of it and use that instance to call readit(some_str)
ReadFileIn rfi = new ReadFileIn(); rfi.readit(string);
There's no real reason to remove the method -- it just sits there like any other method. You just need to make sure that whatever class you invoke from the command line (or however) has a main method -- there's nothing prohibiting other classes from also having a main method.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
How do you remove main()? With the Delete or Backspace key!
Okay, seriously, though. I'm not quite sure what you are asking. As Joel points out, you can have a main() method in every class in your program. There is nothing wrong with this. In fact, it is quite common in order to test individual classes. However, you still need at least one class with main() in order to run your application.