Referencing a class that created another class

Is there a certain way reference the class that created "you" - examples:
public class SomeClass
  public SomeClass()
    // blah blah
    SomeOtherClass foo = new SomeOtherClass();
public class SomeOtherClass
  public SomeOtherClass()
    // blah
  public void SomeMethod()
    // access SomeClass here
    TheClassThatCreatedMe.method();
}Any ideas?

one way is u can modify ur code this way
public class SomeClass{  public SomeClass()  {    // blah blah    SomeOtherClass foo = new SomeOtherClass(String creator);  }}
//where string creator u pass the same clasas name i.e someclass
public class SomeOtherClass{  public SomeOtherClass()  {
System.out.println("created class name is "+creator );
// blah
} public void SomeMethod() {    // access SomeClass here    TheClassThatCreatedMe.method();  }}

Similar Messages

  • Class that creates objects?

    Hello everyone! Im quite new to java and oop, but im enjoying using it quite a lot. I have read some books but everything is so fresh it is easy to get confused. I think this is a very basic questions but, here it goes:
    I have this simple class:
    public class Soda {
    int id;
    int sid;
    String brand;
    String flavor;
    }And now i want to fetch an URL that will return a text string for example "|1|23|Fanta|Orange". Now i want to create a Soda Object from this string (The String could have several Sodas)".... forget the parsing needed and the fectching for the text and everything else (Im using J2ME, and i have it solved)... but more basically:
    how can i make a *method that creates Soda objects*? Funny how i get confused with the simplest things.
    Thank you everyone for your comments and help!
    Alejandro

    AlexR wrote:
    while(something) {
    Soda soda=new Soda();}and each iteration of the while loop will create a different object? or overwrite over and over the created soda object?Each iteraion will create a new Soda object, and overwrite the soda variable with a reference to that object. If you want to have access to all the Soda objects after the loop exits, you need to add references to them to a collection or array.
    [http://java.sun.com/docs/books/tutorial/collections/]
    [http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html]
    Also, you can create constructors that take arguments.
    String brand = (parse brand from string);
    String flavor = (parse flavor from string);
    Soda soda = new Soda(brand, flavor);
    public class Soda {
      private final String brand;
      private final String flavor;
      public Soda(String brand, String flavor) {
        this.brand = brand;
        this.flavor = flavor;
    }

  • Referencing host class from a thread?

    Hello, I need some help with the logic of this. How would I reference the host class (the class that created the thread) from the thread. I want to send a string from a thread (where it is grabbed from the command line) to the class which made the thread.. Thanks!

    Just like when any object of one class needs to access another object. Somewhere you'll have to pass the "host class" (actually "host object reference" is more close) to the thing that implements Runnable or extends Thread (however you designed it), so that the object can hold and use a reference to it.

  • Can I transfer money to other accounts on my iPad with iOS 5.1.1? I created another account and put an iTunes gift card on it, but then I realized that all of my apps are on another account, so how do I move that money over?

    Can I transfer money to other accounts on my iPad with iOS 5.1.1? I created another account and put an iTunes gift card on it, but then I realized that all of my apps ere on another account, so when I recovered the password of my previous account, I had money on an account that I do not want to use. Can I transfer the money over?

    Not on your own. Click here and ask the iTunes Store staff to put it back onto the card; they'll only do this if none of the balance has been spent.
    (115868)

  • Just bought a new macbook w/ mtn lion. transferred data from my old macbook over n it created another user name. that's actually good--xcept for music, which i want on my new acct. How do i move files from my "old comp" acct to my new one?

    i just bought a new macbook w/ mtn lion. when i transferred data from my old macbook over, it created another user name (i called it "old computer"). That's actually good--I'm not going to be accessing old files frequently--except for music, which i want on my new user name. How do i move files from my "old comp" account to my new one? Is there a way to easily move large #'s of files, or just one by one? I've googled extensively but can only find instructions for OSX 10.6 and previous, which talks about the "Shared folder," which I can't seem to find.      

    jesster03 wrote:
    i just bought a new macbook w/ mtn lion. when i transferred data from my old macbook over, it created another user name (i called it "old computer"). That's actually good
    That's actually bad. Peruse Pondini's Setup New Mac guide and seriously consider starting over.

  • I can't get firefox to open. Try creating another profile as suggested in another answer, and it says that firefox has crashed, how do I get firefox working?

    I had to restore my computer to a previous restore point. When I tried opening firefox 4.0, nothing happened. Frustrated, I tried removing the program, but ran into the same problem: nothing happened. I went to Processes in Windows Task Manager, and firefox.exe was not running. Tried using the suggestions to create another profile, and entering the command into run brought up an error saying that firefox has crashed.

    OK - undo the changes you made to DEP.
    Open Firefox - take a screenshot of any message that appears and post back here

  • There were no results for Hi there, I have been using gmail Id and that has been changed by someone into a hotmail apple id whenever I wanted to sign into my account. I am really really troubled a lot. I have also successfully created another apple ID and

    I have been using gmail Id and that has been changed by someone into a hotmail apple id whenever I wanted to sign into my account. I am really really troubled a lot. I have also successfully created another apple ID and password after a lengthy process and tried to go and get downloads, I was asked for my apple id and again the same problem came back and I couldn't be able to use my new account and use apple downloads from iTunes , etc. please, help me as soon as possible. Yimenu

    Apss are forever tied to the Apple ID under which they were originally purchased. If you forgot the password to your original Apple ID, you can retrive it here:
    https://iforgot.apple.com

  • I use iphone 4 ios 6.1. i want to buy whatsapp app buy i cant buy it cos it says the email Id is for U.S why am in Nigeria. if i created another apple id using Nigeria country, will the app work with ma iphone that already have another id to purchase app

    i use iphone 4 with ios 6.1. i want to buy whatsapp app but my previous apple id is for U.S using to get free app while i live in Nigeria. if i create another id for Nigeria region to buy Whatsapp app, will it work with my iphone that already have id?

    Hello Emmanuel,
    It sounds like you are trying to purchase an app on your iPhone while in Nigeria.  You do not need to create a new Apple ID to do this.  You will just need change the iTunes Store country in your iPhone settings and update your billing information to match the country you are in:
    Change your iTunes Store country
    Sign in to the account for the iTunes Store region you'd like to use. Tap Settings > iTunes & App Stores > Apple ID: > View Apple ID > Country/Region.
    Follow the onscreen process to change your region, agree to the terms and conditions for the region if necessary, and then change your billing information.
    You can find the full article here:
    iOS: Changing the signed-in iTunes Store Apple ID account
    http://support.apple.com/kb/ht1311
    Thank you for posting in the Apple Support Communities.  
    Best,
    Sheila M.

  • Domain Admin that can't create another administrator

    Any and all that can provide assistance,
             I am in the military and semi-new to the whole system administration scene. I belong to the administrators group, domain admins, schema admins and enterprise admin. Back in November, i was able to create admin
    accounts with no issue. Recently, I tried creating another administrator account similar to mine and the account that I created is immediately disabled and the user is removed from all of the aforementioned groups.
             Now back in November all of my servers were Windows Server 2003 and now our Exchange is Windows Server 2008, which has caused us some issues creating users with a mailbox but I don't think this is causing
    this particular dilemma. I had two other system administrators try creating the same account and they were met with the same exact issues.
             My thought is that someone had changed something in group policy or the registry that prevents Domain Admins from creating any other sort of administrative account. However, this is highly unauthorized in
    my organization so I sincerely hope this is not the case. My team and I have combed through group policy and have not been able to find anything that would cause this.
            If anyone has seen this, or if anyone can provide any guidance, I would greatly appreciate it. I am not too sure what additional troubleshooting I can do that I haven't done already.

    It sounds like you have a group policy using restricted groups.
    - Open GPMC.msc
    - Look at the GPOs linked to your "Domain Controllers" OU.
    - One of those policies will likely have the following setting:
         - EDIT each GPO and check for the setting:
         - Computer Configuration -> Windows Settings -> Security Settings -> Restricted Groups.
    When you set these groups by policy, you can add a member for about 5-15 minutes until the GPOs refresh on your domain controllers.  If you want to add users to these groups, you must add them with this policy.
    http://technet.microsoft.com/en-us/library/cc785631(v=WS.10).aspx
    - Chris Ream -
    **Remember, if you find a post that is helpful, or is the answer, please mark it appropriately.**

  • I have an account that the email address live, but they stole my account and changed direccionn email to Gmail but now that I have new email in gmail not in me finds the account or reconose me the key and create another account, but the Musia that havi bo

    had a live email account, but the account was stolen and opened an email account in gmail and made the change by hour account but I do not recognize this and create another account with the same email, but in the other account had purchased music, as I can do to recover purchased music.
    The previous Cunta I have it open on a pc but the pc is not mine

    Welcome to the Apple community.
    If you are unable to remember your password, security questions, don’t have access to your rescue address or are unable to reset your password for whatever reason, your only option is to contact Apple ID Support, upon speaking to an operator you should explain that your problem is related to your Apple ID, this way you will not be charged for assistance, even if you don’t have an AppleCare plan.
    The operator will take you through some steps you may have already tried, however they need to be sure they have exhausted all usual approaches before trying to reset your account, so you should try to be helpful and show patience with the procedure.
    The operator will need to verify they are speaking to the account holder and may ask you some questions that only the account holder could know, and you will need to answer them if the process is to proceed.
    Once the operator has verified your identity they will send a message through to your device which contains an alpha numeric code, which you will need to read back to them.
    Once this has been completed they will send an email to your iCloud email address after a period of 24 hours, so you should check that mail is enabled in your devices iCloud settings.
    Upon receipt of the email, use the reset link provided to reset your password, after which you should be able to make the adjustments to iCloud that you wish to do.

  • Calling a method on a jFrame from a jPanel that created by the jFrame

    Hi all
    I can not for the life of me work out how to do this.
    Calling a method on a jFrame from a jPanel that created by the jFrame.
    I have used this code to set a handle for one jPanel to another.
    i.e I can create new jpanel and pass in handles from one to another but not back to the jFrame.
    // this is sudo code
      private Panel_Top topPanel;
      private Menu_Panel menuPanel;
      private DataPanel dataPanel;
    //create new
        topPanel = new Panel_Top();
        menuPanel = new Menu_Panel();
        dataPanel = new DataPanel();
    // add handles from one to another
        menuPanel.setDataPanel(dataPanel);
        topPanel.setDataPanel(dataPanel);
        topPanel.setMenu_Panel(menuPanel);
        dataPanel.setMenu_Panel(menuPanel);
    // in each class I use this to set
      public void setDataPanel(DataPanel dataPanel) {
        this.dataPanel = dataPanel;
      }But I can not seam to get a handle back to the jFrame that created it.
    Please help
    as you can see I am trying but no luck so far
    Thanks

    class Life extends JPanel{
          pulic Life( JFrame owner )
                owner.doSomething(); // pass the JFrame to the constructor and feel free to use it
    }[code[                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • I need to know the Object that created my Object

    help needed!!
    From inside a method of myclass, I want to call a method of the class that created myclass..
    public class BSQL{
    private Manager m;
    public void BSQL() {
    m = new Manager();
    public void beeep() {...}
    The other class:
    public class Manager {
    public void x{
    !!need to call beeep() from the BSQL that created me

    Try this....
    public class BSQL {
         private Manager man;
         public BSQL() {
              man = new Manager(this);
              man.doManagerStuff();
         public void doSqlStuff() {
              System.out.println("Doing stuff.");
         public static void main(String args[]) {
              BSQL b = new BSQL();
    public class Manager {
         private BSQL creator;
         public Manager(BSQL creator) {
              this.creator = creator;
         public void doManagerStuff() {
              creator.doSqlStuff();
    }

  • Opening files in apps that created them

    OSX drives me nuts. Preview is the default for opening files, and when I follow the instructions for "changing all" so all my Photoshop files open in Photoshop, Word in Word, etc., it won't let me do it...it defaults back to Preview!
    So, what can I do to have ALL my files open in the application that created them when I double-click on them, whether they are Classic apps or OSX apps?
    THANKS!
    Paul

    Preview is not the default for opening all files. Each application uses a unique way of identifying its document file - an extension. Word uses ".doc", for example. If you don't make any changes to the default application used the correct application will open when you double-click the document file.
    You can gain more extensive control over file associations by installing the freeware RCDefaultApp (www.versiontracker.com or www.macupdate.com.)
    Perhaps your system needs a bit of maintenance:
    Kappy's Personal Suggestions for OS X Maintenance
    For disk repairs use Disk Utility. For situations DU cannot handle the best third-party utilities are: Disk Warrior; DW only fixes problems with the disk directory, but most disk problems are caused by directory corruption; Disk Warrior 4.0 is now Intel Mac compatible. TechTool Pro provides additional repair options including file repair and recovery, system diagnostics, and disk defragmentation. TechTool Pro 4.5.2 is Intel Mac compatible; Drive Genius is similar to TechTool Pro in terms of the various repair services provided. The current version, 1.5.1, is Intel Mac compatible.
    OS X performs certain maintenance functions that are scheduled to occur on a daily, weekly, or monthly period. The maintenance scripts run in the early AM only if the computer is turned on 24/7 (no sleep.) If this isn't the case, then an excellent solution is to download and install a shareware utility such as Macaroni, JAW PseudoAnacron, or Anacron that will automate the maintenance activity regardless of whether the computer is turned off or asleep.
    OS X automatically defrags files less than 20 MBs in size, so unless you have a disk full of very large files there's little need for defragmenting the hard drive. As for virus protection there are few if any such animals affecting OS X. You can protect the computer easily using the freeware Open Source virus protection software ClamXAV. Personally I would avoid most commercial anti-virus software because of their potential for causing problems.
    I would also recommend downloading the shareware utility TinkerTool System that you can use for periodic maintenance such as removing old logfiles and archives, clearing caches, etc.
    For emergency repairs install the freeware utility Applejack. If you cannot start up in OS X, you may be able to start in single-user mode from which you can run Applejack to do a whole set of repair and maintenance routines from the commandline.
    When you install any new system software or updates be sure to repair the hard drive and permissions beforehand. I also recommend booting into safe mode before doing system software updates.
    Get an external Firewire drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is significant):
    1. Retrospect Desktop (Commercial - not yet universal binary)
    2. Synchronize! Pro X (Commercial)
    3. Synk (Backup, Standard, or Pro)
    4. Deja Vu (Shareware)
    5. PsynchX 2.1.1 and RsyncX 2.1 (Freeware)
    The following utilities can also be used for backup, but cannot create bootable clones:
    1. Backup (requires a .Mac account with Apple both to get the software and to use it.)
    2. Toast
    3. Impression
    4. arRSync
    Apple's Backup is a full backup tool capable of also backing up across multiple media such as CD/DVD. However, it cannot create bootable backups. It is primarily an "archiving" utility as are the other two.
    Impression and Toast are disk image based backups, only. Particularly useful if you need to backup to CD/DVD across multiple media.
    Visit The XLab FAQs and read the FAQs on maintenance, optimization, virus protection, and backup and restore.
    Additional suggestions will be found in Mac Maintenance Quick Assist.
    Referenced software can be found at www.versiontracker.com and www.macupdate.com.
    Why reward points?(Quoted from Discussions Terms of Use.)
    The reward system helps to increase community participation. When a community member gives you (or another member) a reward for providing helpful advice or a solution to their question, your accumulated points will increase your status level within the community.
    Members may reward you with 5 points if they deem that your reply is helpful and 10 points if you post a solution to their issue. Likewise, when you mark a reply as Helpful or Solved in your own created topic, you will be awarding the respondent with the same point values.

  • Is possible to make webservice that call another webservice??

    i already make 1 webservices(a) project and also make a class file that invoke another webservice(b)... when i test with SOAPUI to invoke my webservice(a), it failed. but when i make a main class and run as an application (standalone), everything is going good.
    is possible to make a webservices n invoke another webservices??????? if yes, can u give me an example..???

    yes its possible. I have written a web service that is part of our system that calls a third party system and passing credentials across to amalgamate data from 2 distinctly separate systems. A call is made to my webservice and in the code for that service I invoke a method on a set of stubs built against a third party wsdl.
    Similarly for smart card authentication users first call my webservice, but as I am not responsible for the smartcard validation itself I call another departments webservice, this time its a message based service and not RPC but either way I still build a SOAP message and then send it to a service which then does the smartcard validation for me.
    They are both working examples of a web service calling another web service.

  • Create another purchase order for a material ordered in full

    Hello friends,
    I have a little MM question for you.
    I've created a purchase requisition with a material A and quantity 100 UN
    I've then created a purchase order in reference to this PR.
    This PO has been released.
    Is it possible, in standard SAP, to create another purchase order in reference to the same purchase requisition for the same material and the same quantitiy ?
    How does SAP control that ? (customizing path ??)
    Regards,
    Bahia.

    Dear,
    Is it possible, in standard SAP, to create another purchase order in reference to the same purchase requisition for the same material and the same quantitiy ?  Yes it is possible in SAP
    How does SAP control that ? (customizing path ??): SAP controls in that way, when ever you create purchase requisition with a material A and quantity 100 UN...Now PO created and released...
    Now again if you try to create PO wrt PR, you can observe this time you will get all deatils in PO without quantity...reason behind that is, you have already released an order for full qty w.r.t. that PR...So this time qty field will be empty..You have to manually enter this field.
    Now the same you can see in the the PR status in ME53N Tcode.
    Regards
    Utsav

Maybe you are looking for

  • MacBook Pro (Mid-2009, 13", 2.26) Memory Upgrade Question

    I currently own a MacBook Pro (2.26; 13") (Mid-2009) with 2GB of memory. I purchased a single 4GB memory card that I plan to add in one of the slots. If I understand correctly that would leave me with a total of 5GB of memory (4GB   1GB). Is this wor

  • External Monitor with XP using closed lid on laptop

    Is there a way to turn the laptop screen off and use an external monitor when running Boot Camp and XP pro. I have bluetooth keyboard & usb mouse. Display is cloned but when you close the lid the screen stays on.Some forums indicates its OK for the s

  • Overriding a dynamicdata in 11g

    Hi all, Is it possible to override a dynamicdata table, or to add extra information/custom information into it? so something similar to overriding/extending a dynamichtml ? Thanks, Vlad

  • How to run the LabVIEW exe as background process?

    Dear All,                I want to run my LabVIEW exe as background process, which wont show as the process in the task bar as shown in the .jpeg file.                 I want to run it as a background services as like runs in the windows processes.  

  • "This file could not be copied" when consolidating media?

    I'm trying to consolidate the media in a project. One of the songs I'm using in my project gives me this error message. I can't figure out how to solve it for the life of me... Help?