Multiple classes in the same source file

I'm not sure what this is called, having multiple classes in the same source file. At first I thought it ws called subclassing but then I googled it and found that subclasses are just derived classes. Here's an example of what I'm talking about.
public class A {
class B {
class C {
}So first of all, what is having multiple classes in the same source file called?
Secondly, what are the advantages/disadvantages of this?
Thirdly, can you have a class completely WITHIN a class (same source file but inside the class not outside) and what are the advantages/disadvantages of this?

Advantage: You can reduce the number of source files specialy when your secondry classes are used only in the public class of the file.
Disadvantage: Normaly it make things more clear if we have one-to-one correspondance of class and source files. This make things easy when you want to find the java file of a perticuler class file. Also If you later wanted to create a seperate public class with a same name as one of those secondry classes you got lots of changes to do.
You can avoid this by creating them as nested classes
ex:-
public class MyPublicClass{
   private static class MyInnerClass{
}this way the inner class will create a class file with name "MyPublicClass$MyInnerClass.class" instead of just "MyInnerClass.class"
And also if you declare the inner class as public you can access them from out side

Similar Messages

  • Does a member class have to be within the same source file?

    Hi there,
    I have this application that extensively uses two classes. The main class setsup the GUI, and the second main class is responsible for handling all of the actions that arise from the GUI.
    I could have done this by making all of my handler methods be of the first main class, but this class really is just for the GUI setup, the logic doesn't fit into this class' behaviour.
    The class that handles the GUI actions is required to use the fields of the main class e.g. to get values of a text field. The problem is that since the class that handles the actions is getting very big, I would kind of like to move this class into a different source file - because currently it is a member class of the first one, so that it can access all of its fields.
    Is there some way that I can move this handler class into another source file, and still have it access all of the fields of the main GUI class - without making the fields public, or using millions of get/set methods? Also, I can't use inheritance because the both the GUI class creates an instance of the handler class in its constructor, and so leads to an infinite loop when trying to instantiate the GUI class.
    Can I ask.. would a static class or something be of use here? Do they exist? I'm confused as to how to do this without getting the mother of all source files (in size that is - nothing to do with cooking or baking).
    - Anyway, thanks in advance for any help that you could give me -
    BYEE, Edd.

    You can't have an inner class that is not in the same source file. However, you could use package-protected (default) access to give another class in the same package access to things without making them public. Actually, that's how inner classes are actually compiled. Package-protected access is underused IMHO. It's a great tool that most people (including myself) are suspicious of at first.

  • Export Limits for Multiple Sequences in the Same Sequence File for TS3.0

    Hi,
    I am using TestStand 3.0 to a test application. Because we want to have our limits in a csv-file I have tried to use the Import/Export tools in TS. But this application only supports to export limits for the selected sequence (e.g. main, or subseq1) at a time. This makes it a pretty hard job to export limits from 30 test sequences. What I need is a possibility to export my limits from �all sequences� in my seq-file.
    I have found an article on NI Dev. Zone about �Export Limits for Multiple Sequences in the Same Sequence File (TestStand 1.0.x)�.
    http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3D9CB56A4E034080020E74861&p_node=DZ52236&p_submitted=N&p_rank=&p_answer=&p_sourc
    e=External
    I have tried to use this code but because it�s for TS 1.0.2 the limits from my multi num test step and my custom steptypes isn�t exported. So that doesn�t fulfill my needs.
    Is there an updated version with �all sequences� added to TS 3.0? Is there other good solutions to my problem out there?
    Best Regards,
    Morten Pedersen
    CIM Industrial Systems A/S
    Denmark

    Hi David Mc,
    Thanks for your reply. I have already considered this solution because the source code is added in the folder described in your reply. But that is not a good solution. It will cost me a lot of time to establish the toolchain, reverse engineer the source code, make the implementations and build a new dll (most off these is already knowledge by NI). And when NI make future releases of TestStand I have some merge work to do every time NI have made some changes in the files I have changed.
    But as I write above: I have hoped that NI already has/or could made a solution like the one to 1.0.2 (see link in root) to me. And then they could include it in the next version.
    I don't think I am the only one in the TestStand world that ne
    ed this feature.
    Best regards,
    Morten Pedersen
    CIM Industrial Systems A/S
    Denmark

  • Multiple instances of the same source clip in Project bin

    This is a strange one.
    I think its more an issue now than ever due to tapeless format editing. I edit lots of video now shot on Canon 5d. They sometimes have thousands of individual clips.
    The problem is that our project files are getting huge and premiere slows to a grinding halt.
    We copy paste lots of timelines from one project to another. When we paste, all of the source clips land in the project bin (as you would expect) However, sometimes I have already made reference to the same source files in the edit to begin with (So they are already in the project bin)
    However, when I paste a new timeline, it will make another reference to that same source clip in the project bin. Therefore double up reference to a souce clip in the project. Increasing the clips in the overall project, which bloats everything and slows premiere down.
    Can premiere be smarter? Can it see that the source file already exists in the project and link to that existing file instead of creating another reference to the same file?
    Hope that makes sence.

    I am beginning to think that there is no easy way around this issue.
    I have started to use Final Cut and am noticing lots of differences between the two platforms. I have been a Adobe Premiere user for 10 years and I concider myself a NINJA using this program. However, there are definitly differences between the two, this being one of them.
    Final cut does not double up on source references in your project bin when copying one sequence from one project into another.
    CLEVER
    Its annoying that premiere doubles files up as it gets ridiculously messy in your project bin. Double ups, triple ups, quadruple ups the list goes on.
    Its strange cause when you start a Prem project from scratch and import a source clip, you can set in and out points as many times as possible and drag onto the timeline, and it does not duplicate the original source file in the project bin. Thus keeping your project bin neat and clean. However, as soon as you paste a sequence, it goes and duplicates refeneces like its outta control, rather than looking at what you alraedy have in your project bin and saying to itself. (Hmmm well the source clip is already here, so we dont have to duplicate this one....move onto the next file)
    Prem is great at lots of things, dont get me wrong. I freaking love the program, however, things like this let it down as the program becomes unusable as it gets bogged down with way too many clip references.
    Hmmm, we shall see who wins the day in the end. Time do do some Final Cut edditing now.
    P.S. Final cut can do 16 multi clips in a real time edit. Premiere...only 4...come on Prem, pick up your game!

  • Add multiple scans to the same pdf file scan at time of scanning

    Hello, HP Officejet Pro 6830 How do I get it to add multiple scans to the same pdf file? I need to scan multiple documents and have them all end up in one pdf. Some may be double-sided and it is fine if I have to scan them individually. At present it will only do one scan or a double-sided scan then it wants to save the scan and not ask if there are any more pages. The only option is to save or not. Thank you.

    After your first scan you need to click the + sign at the 7 o'clock position. 

  • Scan multiple pages to the same computer file

    How can I scan multiple pages to the same computer file on my HP Officejet Pro 8600 Plus?  Currently it will only scan each page to a separate computer file.  I scan one document and then when it asks if I want scan another page I say yes and scan it.  However they still go to separate computer files. 
    Thanks!
    This question was solved.
    View Solution.

    Thanks so much!

  • Multiple download of the same JAR file

    We have a collection of applets packaged in a single JAR file. Some users (web developers that use our applets) have been complaining that the applet is extremely slow to start up.
    When the html page includes more than one applet from the same JAR file then, "ONLY IN SOME CASES", the JAR file is downloaded multiple times.
    By capturing network traffic we can also think that the JAR file is downloaded even when accessing an image packaged in the applet's own JAR file.
    One further detail: this "DOES NOT OCCUR" when there is a fast connection to the server (or at leat it seems so). In these cases, the JAR file is downloaded once. It looks as if the problem only occurs on slower network connections.
    Thanks in advance for any help.

    Mmm... I don't think this is the solution... all the applets share a lot of classes (the big part of the JAR files).
    But my question is....: why in some cases the JAR is downloaded more than once???

  • How to delete multiple versions of the same song file?

    I recently moved my iTunes music file to an external hard drive, and for some reason, it took iTunes a few tries before it recognized the new location of my music (I had to change the location in the preferences a few times because it kept changing itself back...?) So I ended up with those infamous exclamation points next to all of my songs because iTunes couldn't find any of the files.
    I ended up just deleting my entire library and re-adding it to try and solve the problem, but somehow, in the process, iTunes made (sometimes multiple) copies of almost everything. The weirdest part of this is that most of the albums have 3 copies of everything, a few have four (?!), and some did not get copied at all.
    There has to be an easy way to consolidate and delete mutiple versions of the same file, but how? I have tried everything I can think of. The "consolidate library" function tells me it is going to copy everything again (how is that "consolidating"?)
    I have 15GB of music and do not want to go through and delete thousands of songs manually.
    HELP!

    This doesn't quite work as it displays all of the tracks that have been duplicated, including the originals, meaning I would delete all of the copies and no longer have those songs, or still have to go in manually for everything.
    I also tried displaying the date added for everything, hoping iTunes had made the copies on different days, but everything was added and copied on the same day, so I wasn't able to differentiate the files that way, either.
    HELP!

  • PDF file transfer writing target file with the same source file name

    Hi to all,
    I want to transfer a PDF file from a SOURCE folder to a TARGET folder. My problem is that I want the target pdf file has the same name of the source pdf file. How can I do this? I have to look for some parameters in the sender or receiver channels?
    Thanks to all.

    Hi Gabriele,
    If you want to FTP the pdf file from source to target directory, use this blog.  It doesn't require any IR devlopment.
    /people/william.li/blog/2006/09/08/how-to-send-any-data-even-binary-through-xi-without-using-the-integration-repository
    Also, In sender and receiver comm channels select "Set/Use Adapter specific message attributes" and "File Name" to get the same file name in the target directory.
    Regards,
    Sreenivas

  • Zip'ing files from multiple folders to the same zip file

    Could somebody recommend a method to create a zip file with file contents from multiple folders? Or is there an application I can drag and drop a bunch of files to zip em?

    First highlight all of the folders or files. If they're not right next to each other, or on the same drives, hold down the Command key while clicking to choose the next without losing previous choices.
    Once they're all highlighted, right click on any highlighted item and choose "Compress xxx Items".

  • Multiple classes accessing the same DLL???

    This behaviour is completely unacceptable.
    Let's visualise my app:
    There a 2 java classes:
         ClassA:
              public String[] getPaths(){
                   return getNativePaths();
              public native String[] getNativePaths();
              static{
                   System.loadLibrary("mylib");
              }     ClassB:
              public void setPaths(String[] paths){
                   setNativePaths(paths);
              public native void setNativePaths(String[] paths);
              static{
                   System.loadLibrary("mylib");
              }     MainClass:
              public void testA(){
                   ClassB clsB=new ClassB();
                   String paths[]={"c:\\test.txt"};
                   clsB.setPaths(paths);
              public void testB(){
                   ClassA clsA=new ClassA();
                   String paths[]=clsA.getPaths();
              public void testC(){
                   ClassA clsA=new ClassA();
                   String[] paths=clsA.getPaths();
                   clsA=null;
                   ClassB clsB=new ClassB();
                   clsB.setPaths(paths);
              }Method testA and testB in MainClass don't pose any problems, they work fine. :)
    But when calling testC, I get this:
    java.lang.UnsatisfiedLinkError: no mylib in java.library.path
         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)
         at java.lang.Runtime.loadLibrary0(Runtime.java:788)
         at java.lang.System.loadLibrary(System.java:832)
         ...ClassA and ClassB both work good if used separately (another thread). But if we call one after another (same thread), an exception is thrown.
    So, what's the problem here?
    Is it the return of a string array?

    1 remark:
    If I do this:
        ClassA clsA=new ClassA();
        ClassB clsB=new ClassB();
        clsB.setPaths(clsA.getPaths());This works, but if you call the dll again after this, you'll get the same exception over and over again.
    I think it has something to do with the release of strings (cause there isn't any).
    My native code that returns an array of Strings:
        jobjectArray strArray=null;
        strArray=env->NewObjectArray(nSize,env->FindClass("java/lang/String"),env->NewStringUTF(""));
        // loop
        env->SetObjectArrayElement(strArray,nCount,env->NewStringUTF(dlg->GetNextPathName(pos)));
        nCount++;
        return strArray;

  • Multiple Projects Using the Same Video Files

    I have just completed a video that has upwards of 500 clips of source video in a single Bin. Now, I want to create two new videos using some of the previously used video footage in addition to video from other projects completed a couple of years ago. A few questions:
    For new Video #2 (using some of the video from the exisiting Bin)
    1. Can I just create a new Sequence and use some of the previosly used video clips? Will this affect the exisiting movie (ie take the clips offline?)
    For new Video #3 (using some of the video from the exisiting Bin and video footage from other previosly completed videos)
    2. Do I copy and paste the video file into a new project? Will this affect any of the previously completed movies by taking clips offline, etc?
    Any help / suggestions would be greatly appreciated.

    1. Yes. Creating a new Sequence is the proper way to do it. It will not affect the existing movie. It will not affect the underlying clips and will not take the clips offline.
    2. Import the previously completed video(s) into your current project. Create a new sequence. Build your new video using the clips from your existing bin plus the clips you import. It will not affect the existing movie or the existing clips. It will not take the clips offline.
    FCE is a nondestructive editor. That means that basically nothing you do while editing a sequence affects the underlying files on your hard drive. All the edits & effects, etc. are contained in the FCE project file.

  • How to load data using two maps for the same source file in Import Manager

    Hi,
    I am trying to load the source data to MDM using two map files, since one map is too big (creating memory error).
    However the first map data able to see after loading (SAP data) but when loading second map(nonSAP data) using the remote key to match the previously loaded SAP key ,even if MDM is processing the data it is not reflecting in data manager.
    Is there any reason for this.
    Appreciate your suggestion and tips on this.
    regrds,
    Reo

    Hi Reo,
    As ur requirement seems,In the second pass perform recording matching by select default import action as "<b>update null fields only"</b> for those data records which are matching and "<b>create</b> " for those data records which are not matching with previous data records from SAP system.
    If you define "update null fields only", then only the key of the new record from NON SAP will get appended to the existing record. And if you select "create" then it will create new records and will apply NON SAP key on it.
    Please check the remote key values using data manager.Key is applied in the records or not.
    Remember that import maps are client specific. Remote key comprises of both key and client system.So be sure that you are connecting to two different client systems.
    I have tried this and this is working fine on my system.
    Thanks,
    Shiv Prashant Dixit
    Thanks,

  • Multiple versions of the same RAW image

    Hi All,
    It's posible to have multiple versions of the same RAW file. Let's say I work my RAW file and make some changes, can those changes become an independent file? I want to be able to go back to the original RAW file without loosing any other version already created.
    Best regards,
    Jose

    Hi Kim,
    May be you can try this and see if this works for you. I am not 100% sure if it will work for you, but worth a try I guess. Create a Test WebDynpro project and try the following steps on this project. If they work  out correctly and serve the purpose for you only then try them on your actual Web Dynpro project.
    1. Create a test Web Dynpro project  say "TestWDProject" with Component say "Comp1" and the default views and windows etc.
    Also create some working application our of this component and Windows using the Context.
    2. Right click the "Comp1" and select Copy.
    3. Right click 'Components" node in the project structure and select "Paste"
    4.This step will try to paste the copy of Comp1 as a new Component.
    5. You can change the Name and Package of the Component.
    6.Similarly you'll get the prompts for views,windows etc.
    7.Once you have copied everything, Just check if everything looks good.
    8.Now you can create a new Application using this new component and the Component Interface View and Deploy it.
    9.Test whether the Application created out of this copy works same as the original component.
    You can also try to create another Web Dynpro project and paste the Comp1 in the Components node of that new project and perform the same steps.
    Again, try with these Test Projects and see if this serves your purpose before applying the steps on actual projects.
    Regards,
    Ajay

  • Can We Use Multiple Edgehero Classes On The Same Element?

    Does anyone know if it is possible to add multiple Edgehero classes to the same element? More specifically, I would like to use RotateX and RotateY on a rectangle, but it only seems to do one or the other, adding both classes to the element doesn't make it rotate in both directions.

    Maybe check out the Star Wars demo to see if that would help.
    Rob got the idea from the one I made earlier and here is the code:
    sym.$('gradient').css('background', '-moz-linear-gradient(top, rgba(0,0,0,1) 0%, transparent 100%)');
    sym.$('container').css('-moz-transform-origin', '50% 100%');
    sym.$('container').css('-moz-transform', 'perspective(250px) rotateX(25deg)');
    // Chrome and others
    sym.$('gradient').css('background', '-webkit-linear-gradient(top, rgba(0,0,0,1) 0%, transparent 100%)');
    sym.$('container').css('-webkit-transform-origin', '50% 100%');
    sym.$('container').css('-webkit-transform', 'perspective(250px) rotateX(25deg)');
    // Internet Explorer
    sym.$('gradient').css('background', '-ms-linear-gradient(top, rgba(0,0,0,1) 0%, transparent 100%)');
    sym.$('container').css('-ms-transform-origin', '50% 100%');
    sym.$('container').css('-ms-transform', 'perspective(250px) rotateX(25deg)');
    and the orginal file before edgeHero;
    https://app.box.com/s/068vx5x6lj5t2yydrx17

Maybe you are looking for

  • Can't find Printer for AirPrint

    So I have an Canon MX432 printer that is air-print enabled. However, when I try to print from my iPad 4 it says "No AirPrint Printers Found". I have looked into this and I have the latest printer firmware, but it's still not working... help?

  • 4x NVIDIA GeForce 7300 GT cards in a Mac Pro run below max supported speed

    Hi, We have 4 "identical" NVIDIA GeForce 7300 GT 256MB cards in one Mac Pro (to support 8 DVI monitors for a Network Operations Center). One card came with the system, the other cards were purchased from Apple at the same time. This was a refurbished

  • Shuffle is not recognized by windows xp or itunes.

    I have a ipod mini that is working wonderfully but when I tried to connect my son's shuffle - nothing happened. I have reinstalled ipod software & itunes, charged and reset the shuffle - everything I could think of. I am unable to restore it because

  • One Library for all users on the system - Sharing?

    Hello. I'm using iTunes 9.0.3 on OS X 10.6.2. On this system, there are TWO users, one for my wife, one for me. I'd like to "merge" the seperate iTunes libraries, so that there's only one shared library for all users. How could this be achieved? Sear

  • Increase  of number of digits in pricing

    Hi, Can any one suggest me how to increase the number of digits in pricing. For example, currently the system allows you to enter 10 digits, how can I enter 11 digits in the pricing field? Helpful answer will be given points Regards Sudha