Results 1 to 3 of 3
- 02-14-2009, 02:40 PM #1Member
- Join Date
- Feb 2009
- Rep Power
- 02-14-2009, 03:19 PM #2
Think of it as classes, not java files. Unless very small, each java class needs to be in one java file. If you have very small classes, sometimes they may be grouped together in 1. But you cannot split one class into 2 java files, I can't really see what the point of that would be, then you would have to open another file to see the other part of your class. So the answer is No, but I'm curious as to why you even wanted to. Also, you're not being very specific with "code". If all your code consists of many classes, of course, give them each a separate file, but if it's only one class, leave it as it is.Tell me if you want a cool Java logo avatar like mine and I'll make you one.
- 02-14-2009, 04:48 PM #3
Yes... you can (and in some cases should) have your code in different classes. It should depend on the function of the methods in the classes. For example, you can have a "file" class and it has various methods related to file management (open, read, save, copy, etc). Then you may have another class that has methods that have to with input and output (user input and printing and logging).
Here's a couple of links that may help:
The Java™ Tutorials
Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- By CaptainMorgan in forum New To JavaReplies: 1010Last Post: 06-25-2015, 05:43 AM
- By Bhavis in forum Advanced JavaReplies: 4Last Post: 01-21-2009, 07:06 AM
- By coolFrenzi in forum Advanced JavaReplies: 3Last Post: 11-17-2008, 11:45 PM
- By Zosden in forum Advanced JavaReplies: 9Last Post: 05-01-2008, 04:48 AM
- By Java Tip in forum java.langReplies: 0Last Post: 04-23-2008, 08:06 PM