Can you have multiple classes in one .java file ?

or am I being dumb ;-)
I'm guessing not because the filename has to match the classname but maybe you can ... ?
C

To elaborate a bit more. The public class must match the filename, however you can declare "inner" classes.
An inner class can be declared inside another class, or even inside another method. Where you declare that class dictates the scope it will have. However, the lack of an ability to declare these classes public (a public class must be declared inside a java file with the same name), means that they are not visible anywhere else. However, they do still have plenty of uses.
Declaring a class inside a method is used rarely, but would look something like
public void foo(Bar myBar = new Bar
        private String baz = "Hello";
        public String doSomething()
             return baz;
     myBar.doSomething()
}This declares and implements the class Bar inside the method header. Sure, this is a pretty useless example, but you could put any methods or variables inside your inner class, and they would be available only during execution of that method. (ie. only have method scope).
}

Similar Messages

  • Can you have multiple users for one account?

    Can you have multiple users for one account? if so how do you set it up.
    We are using it for our department and it would be great to see who created what form instead of it being all one name.

    Each person should have their own account. You can easily share the forms with other people in your department. You will be able to see who the author of the form is.
    More information on how to share :
    http://forums.adobe.com/docs/DOC-2462
    Information on how to copy a forms to a different account :
    http://forums.adobe.com/docs/DOC-1390
    Hope this helps
    Gen

  • Can you code 2 classes into one source file?

    Can you have 2 classes coded in one source file? If so, do you end up with 2 .class files after the compile?

    yes you can code 2 classes in one source file. I
    believe that you have to reference one class is an
    "object" class of the class under which you save the
    file as.
    Example:
    File name is A.java
    class A{
    class B{
    When you want to refer to class B, you have to say
    A.B ( eg: A.B ab = new A.B() ). The class file(s)
    will be A.class and A$B.class.
    This is what I recall at best at the time. good luckI presume you mean when one is an inner class? Otherwise:
    public class one {
      one() { System.out.println("one");
      public static void main( String[] argv ) {
        new one();
        new two();
    class two {
      two() { System.out.println("two");
    }Will work fine, and will create one.class and two.class. But that does not mean it is a good idea to do it ;o)

  • Can you have multiple ipods under one itune accounts on one computer same log in

    i have nurmeous ipods and iphones and i have 4 different log ins on my computer for them can i have them all under one log in without resyncing and putting songs and pictures on each one???

    "How to use multiple iPods with one computer" http://docs.info.apple.com/article.html?artnum=300432

  • Can you have multiple Rates within one Work Center with multiple operations

    We have a work center called Pipeshop.   Within the Pipeshop we have multiple operations such as Welding, Threading, Cutting, Grooving etc.  Each of these operations have a different cost assoicated with them.  How can you have different cost for these operations? 
    Thank you,
    Loretta

    Hi,
    For this case you need to do following activities.
    1 Create individual activity accoding to requirement, that will be used for costing.
    2  Activity planning w r t work center.  In this cost per unit is declaring.
    3. Create Routing and modify the default activity type, w r t required activity type, suitable to operations.
    Now  Order is referring the activity type, refered in Routing rather than, work center.
    Regards
    Gururaja Hebbar

  • Can you have multiple accounts in one library?

    I've had two iTunes accounts for several years now, and it was never a problem on my old laptop--I needed the second account because I wanted to use a giftcard from outside the US, and the credit refused to apply to the US iTunes store.  However, I replaced my computer about a month ago, and the new version of iTunes won't download my iTunes purchases automatically.  When I try, it says it's already associated with another account, and it will add restrictions if I set it to automatically download purchases.  I don't know what this means, but I'd like a way around it.  I don't want to have multiple libraries (which seems to be the only way I've seen other people on the forum use multiple accounts); there's music on both accounts that I listen to all the time.  I've been stuck working off of two computers for a month now, and it's getting frustrating.  Help?

    To elaborate a bit more. The public class must match the filename, however you can declare "inner" classes.
    An inner class can be declared inside another class, or even inside another method. Where you declare that class dictates the scope it will have. However, the lack of an ability to declare these classes public (a public class must be declared inside a java file with the same name), means that they are not visible anywhere else. However, they do still have plenty of uses.
    Declaring a class inside a method is used rarely, but would look something like
    public void foo(Bar myBar = new Bar
            private String baz = "Hello";
            public String doSomething()
                 return baz;
         myBar.doSomething()
    }This declares and implements the class Bar inside the method header. Sure, this is a pretty useless example, but you could put any methods or variables inside your inner class, and they would be available only during execution of that method. (ie. only have method scope).
    }

  • Can you have multiple users on one apple Id and utilize iCloud?

    My family shares an apple Id and we each have multiple Apple devices. When we use iCloud we "cross pollinate" each others devices with contacts, calendar events, etc.  is it possible to manage multiple users on one apple Id with iCloud activated or are separate ID's required?

    iCloud isn't designed as a multi-user service. Either you all have the same ID, and all your data is available to everyone, or you all have separate IDs and keep your data separate. You can share calendars, so that for example you could all have your own calendars but have one which is common to everyone:
    http://help.apple.com/icloud/#mm6b1a9479
    If you want to share contacts you will have to do it manually. If you want to do file transfer you will have to find a third-party alternative.

  • HT204053 can you have multiple devices on one apple id?

    i ahve added a new iphone to may wireless account but both phones are now using the same apple id.

    Not sure what your question is? You can have multiple devices signed on to the same Apple ID. Do you have any other questions concerning that?
    Cheers,
    GB

  • Can you have multiple clickboxes on one page

    Sorry... a few complicated things are coming up. I am doing a
    large project with LOTS of interactivity, which involves simulating
    a customer filling in a form and then clicking a button to move on.
    So one one page I have both a Text Entry box, and sometimes also a
    click box.
    I made the Text Entry box action "none," and put the "go to
    next" on the click box action.
    Now my boss wants two more links added to each and every
    page... a TABLE OF CONTENTS button, and also a NEXT PAGE button.
    When I added these two additonal buttons, it seems to be confusing
    Captivate.
    This is understandable, as Captivate is probably thinking
    "what the heck do you want me to do first."
    What I need to know is (a) is it possible to have multiple
    Interaction buttons or clickboxes on the same page, each doing a
    different thing; and (b) if so... how???
    (Secretly I hope the answer is NO because it will simplify my
    life tremendously).
    Thank you, QuizQueen

    Hi again QuizQueen
    Of course you may have multiple Buttons or Click Boxes on a
    single slide and have each do something different when the user
    clicks. It's all in how you configure the Buttons or Click Boxes.
    Personally I think it's easier if you use Click Boxes as I
    believe them to be more flexible.
    Often what is missed is a specific setting. When you look at
    the Options tab of the Click Box properties, you should see a
    button with a down arrow. This button is located to the immediate
    right of where you would type a URL. Click that button and you
    should see an option to open the destination in a new window. But
    click again and you see another option that is easily missed. This
    would be the option to "Continue playing project". That one is
    easily missed because it was in a disabled state (grayed out)
    initially. So if you DE-select this option, the Click Box or Button
    will carry out its assigned action without releasing the pause on
    the slide.
    Hopefully that helps you better understand it.
    Cheers... Rick

  • HT1206 can you have multiple itunes accounts one computer with seperate music library for multiple iphones?

    is it possible to seperate multiple itunes store accounts and music libraries on 1 computer for 2 iphones ?

    Welcome to Apple Support Communities
    You just need to create a second iTunes account on your PC or Mac.
    To do it, open iTunes while holding down the Option (Alt) key (on a Mac) or the Shift key, and press the option to create an iTunes option. You will have to open iTunes with that key when you want to switch libraries

  • Friend has new iPod touch but no computer - can you have multiple devices under one account number?  If so how do I do it?

    I have an iPod and have an account set up already with iTunes.  My friend has brand new iPod touch but no computer.   She only wants to download CDs onto iPod but I couldn't seem to do this without being prompted to set up an account or it overriding the information for my iPod - any help would be appreciated.

    How to use multiple iPods, iPads, or iPhones with one computer

  • Can you have multiple itunes accounts on a single computer?  want to open a separate one for our daughter (but we will manage it).

    just got our daughter a new iTouch, but want to try and keep hers separate from our iPhone stuff.  can you have multiple iTunes accounts on a single computer?

    This is all i know but all you can do is just creat a new one for them both and send all the stuff to the one think u can do that i hope it helps

  • Can you have multiple iCloud's with one Apple ID?

    Can you have multiple iCloud's with one Apple ID?

    You can have multiple iclouds with multiple id's

  • Can you have multiple Apple TV's in the same house and network? If so how do you know which one to pick from your Idevice?

    can you have multiple Apple TV's in the same house and network? If so how do you know which one to pick from your Idevice?

    Yes, there are even defaults for naming them, such as LivingRoom, Bedroom, etc, or you can even enter your own name with the remote for each AppleTV.

  • In iPhoto can you label multiple photos in one step or do you have to label them one by one?

    In iPhoto can you label multiple photos in one step or do you have to label them one by one?

    what are you calling a "label"  You can set the title for multiple photos by selecting them and using the batch change command
    LN

Maybe you are looking for

  • Error Message with CD drive in itunes

    I get the following error message: itunes was not properly installed.  if you wish to import or burn cds you need to reinstall itunes.  I have reinstalled multiple times and I know the drivers for my cd are fine as well. I have Windows Vista 32 bit s

  • My ipod nano doesnt have enough battery for the computer to recognize it

    Well my ipod nano is really screwed up! Ok so a couple weeks ago I plugged my ipod into my computer because the battery was getting pretty low, and my computer didn't recognize it so i restarted the computer plugged it into a different port and it st

  • IWork software deleted itself from computer

    Hello, This is an unusual one.... Somehow, all iWork software has removed itself from my computer. I am definite that I did not accidentally uninstall it.  I checked the app store purchases, and keynote and numbers are showing up. Pages does not seem

  • Slow finder save as...

    When I save out of Mac Mail often there is a very long delay before the save as window pops up. Same happens in Photoshop. Any bright ideas how to speed things up?

  • Can i make a button download a pdf?

    i have a button made in flash and im using it for a sidebar navigation in my dreamweaver site can i make the button open/download a pdf? and if so how do i go about doing this? thanks