Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 2
Registered: ‎07-20-2008
My Device: Not Specified

Can more than one non-nested class be declared in a java file?

I have a package in a separate java file that I have one class in already, namely Spacer, a derivation of a RichTextField.  It works fine when I import it from my main java file.  However, if I try to add another class to the same file that Spacer is in, the compiler complains that the new class eg FancyFontField should be in its own file.

 

The short question, does every class need to be in a separate file?

 

Sorry, I am still a noob.

Developer
Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: Can more than one non-nested class be declared in a java file?

There are specific reasons why you might want to put multiple classes in the same file or use inner or nested classes; but for what you're doing, yes, you should put that in its own file of the same name as the class's name.