Help,Could anyone can explain this to me ?

public class A {
B b;
     private int a;
     * @param args
     public int get(){
          return this.a;
     public static void main(String[] args) {
class B{
     private int b;
     A a;
     public int get(){
          return this.b;
There is a reference to A in Class B,and There is a reference to B
in Class A,I am confused about this,could someone explain it to me ?

learnningboy wrote:
There is a reference to A in Class B,and There is a reference to B
in Class A,I am confused about this,could someone explain it to me ?For example, there's a road between city X and city Y that goes two ways (you can travel from X to Y and you can also travel from Y to X). That's the idea: both cities hold a reference of each other in them.

Similar Messages

  • Anyone can explain this program to me?

    import java.util.List;
    import java.util.LinkedList;
    import java.util.Iterator;
    public class Lab_02
         public static List getLinesOfText(int m)
    {      List lines = new LinkedList();     
              StringBuffer line = new StringBuffer();
              for( int i = 0; i < m; i++ )
    {         for( int j = 0; j < m; j++ )           
                   line.append( j < i ? " ": Integer.toString(i%10) );
         lines.add(line.toString());
                   line.setLength(0);
                   return lines;
         public static void main(String args[])
         int n = 15;
                   if( args.length > 0 )
                   try
         {            n = Integer.parseInt(args[0]);
         catch( NumberFormatException nfe )
         {        String msg = nfe.getMessage();
              System.out.println(msg);
         Iterator lineIterator = getLinesOfText(n).iterator();
         while(lineIterator.hasNext())
              System.out.println(lineIterator.next());

      public static void main(String[] args) {
        int n = 15;
        if( args.length > 0 ) {                     // if an argument was entered
          try { n = Integer.parseInt(args[0]); }    // change it to an int
          catch( NumberFormatException nfe ) {      // if bad format
         String msg = nfe.getMessage();          // print a message
         System.out.println(msg);
    //  call getLinesOfText(with the above number, it returns a List),
    //  get an iterator for that list, and
    //  assign that iterator to lineIterator
          Iterator lineIterator = getLinesOfText(n).iterator();
    //  loop through the iterator printing each value
          while(lineIterator.hasNext()) System.out.println(lineIterator.next());
      public static List getLinesOfText(int m) {   // m = count from call above
        List lines = new LinkedList();             // make a LinkedList, assign to lines
        StringBuffer line = new StringBuffer();    // make a StringBuffer, assign to line
        for( int i = 0; i < m; i++ ) {             // loop m times
          for( int j = 0; j < m; j++ ) {           // for each value of i, loop m times
    // append either a space or the string representation of i modulo 10
    // to the StringBuffer depending on whether j is less that i
    // (modulo = remainder after division by 10)
         line.append( j < i ? " ": Integer.toString(i%10) );
    // Add the string representation of line (a StringBuffer) to the linkedlist lines
          lines.add(line.toString());
    // Clear the StringBuffer
          line.setLength(0);
    // return the linked list
        return lines;
      }

  • Can anyone please explain this code to me?

    I am a new (junior)programmer?Can anyone please explain this code to me in lame terms? I am working at a client location and found this code in a project.
    _file name is AtccJndiTemplate.java_
    Why do we use the Context class?
    Why do we use the properties class?
    package org.atcc.common.utils;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Properties;
    import java.util.logging.Logger;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import org.springframework.jndi.JndiTemplate;
    public class AtccJndiTemplate extends JndiTemplate
      private static Logger logger = Logger.getLogger(AtccJndiTemplate.class.getName());
      private String jndiProperties;
      protected Context createInitialContext()
        throws NamingException
        Context context = null;
        InputStream in = null;
        Properties env = new Properties();
        logger.info("Load JNDI properties from classpath file " + this.jndiProperties);
        try
          in = AtccJndiTemplate.class.getResourceAsStream(this.jndiProperties);
          env.load(in);
          in.close();
        catch (NullPointerException e) {
          logger.warning("Did not read JNDI properties file, using existing properties");
          env = System.getProperties();
        } catch (IOException e) {
          logger.warning("Caught IOException for file [" + this.jndiProperties + "]");
          throw new NamingException(e.getMessage());
        logger.config("ENV: java.naming.factory.initial = " + env.getProperty
    ("java.naming.factory.initial"));
        logger.config("ENV: java.naming.factory.url.pkgs = " + env.getProperty
    ("java.naming.factory.url.pkgs"));
        logger.info("ENV: java.naming.provider.url = " + env.getProperty
    ("java.naming.provider.url") + " timeout=" + env.getProperty("jnp.timeout"));
        context = new InitialContext(env);
        return context;
      public String getJndiProperties()
        return this.jndiProperties;
      public void setJndiProperties(String jndiProperties)
        this.jndiProperties = jndiProperties;
    }

    Hi,
    JNDI needs some property such as the
    java.naming.factory.initial
    java.naming.provider.url
    which are needed by the
    InitialContext(env);
    where env is a properties object
    Now if you can not find the physical property file on the class path
    by AtccJndiTemplate.class.getResourceAsStream(this.jndiProperties);
    where the String "jndiProperties" get injected by certain IOC ( inverse of control container ) such as Spring framework
    if not found then it will take the property from the system which will come from the evniromental variables which are set during the application start up i.e through the command line
    java -Djava.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory -Danother=value etc..
    I hope this could help
    Regards,
    Alan Mehio
    London,UK

  • When I try to enter codes for digital movie downloads it tells me "code redemption is temporarily unavailable. Try again later." Customer support has been no help. Anyone else have this problem?

    When I try to enter codes for digital movie downloads it tells me "code redemption is temporarily unavailable. Try again later." Customer support has been no help. Anyone else have this problem?
    Am sick of going back and forth with what has turned out to be worthless customer support. Have sent them so much info and pictures, no help. All they do is send me links for instructions on how to redeem the codes. I know how to redeem, I have redeemed at least 50 codes. To them I am obviously an idiot though. To me it seems to be a problem on their end, but can't get an answer from them on why it is telling me code redemption is unavailable. Please help! Anybody!

    Confirming my suspicions with every passing hour. Support on this forum is non-existent like the support from Apple support. But, you got my money now... why would you care?

  • I have a problem in my iphone 4 with wi-fi after update to IOS6 please can help my how can solve this problem?

    I have a problem in my iphone 4 with wi-fi after update to IOS6 please can help my how can solve this problem?

    Nope
    One needs to press the home and sleep / wake keys together for the phone to reset
    The other thing I could recommend
    Let the battery run out and the phone completely "die"
    It may take a day or two with it not being used
    Then plug it in to charge and see if there is any change in behavior
    If you cannot get this to work - you may need to bring it to an Apple store

  • The Director role is optional in Lync Server 2013 - could anyone please explain why the director server has lost its importance??

    Could anyone please explain why the director has been removed from spotlight as it had much importance in LYNC 2010 and now being an optional role in LYNC server 2013.[any call flows regarding director servers would be much useful]

    Hi SJ Praveen,
    A Director is a server running Lync Server 2013 that authenticates user requests, but does not home any user accounts. Lync 2013 Front End servers have the same registrar service and functionality
    as the Director.
    The Director isn't providing any special functionality. If the Director goes down, all pools would become inaccessible when the clients queried DNS for the SRV record until an administrator
    makes a manual internal DNS change that points users to a Front End pool to handle the sign-in request from Lync clients. Microsoft has made the Director functionality relevant for organizations that have specific security requirements, such as allowing all
    external users to register to a specific internal server instead of the Front End servers. This server role is merely optional and not needed for most Lync Server 2013 deployments.
    Best regards,
    Eric

  • Please add the option to be able to upload/link new pdfs with the in-browser editing. I have a restaurant client who is constantly updating their menu! Please help so they can do this themselves!

    Please add the option to be able to upload/link new pdfs with the in-browser editing. I have a restaurant client who is constantly updating their menu! Please help so they can do this themselves!

    Thank you so much for your help! I am so relieved. I will have explain how to do this to my client, but a big weight is off my back!
    A long learning process and actually such an easy fix. So glad you responded. Again thank you...

  • The verification lists my card data and address etc. correctly but I need to keep entering the card security number.  Support keep telling me to delete and re-enter my car info which does not help. Anyone else seen this issue?  Seems to be something to do

    The verification lists my card data and address etc. correctly but I need to keep entering the card security number.
    Support keep telling me to delete and re-enter my car info which does not help. Anyone else seen this issue?
    Seems to be something to do with a new security check they have put in the system that does not work correctly and support is totally incapable of helping me out.
    wth am i gonna do im feed up and on top i have no one to help me been calling itunes for days now im ****** off to the maxxx

    I've been jumping through the hoops with Apple Support on this issue....first time I called they said I should try updating from IOS 4.0 to 4.1....tried that and the issue still persisted...then I called back to update the ticket and get the next steps...they said that the Bank is rejecting the request for verification and that is why it keeps prompting (which doesn't make sense since the confirmation seems to go through successfully). The rep also contacted the iTunes dept and had them run the verify manually and said the bank rejected it. The next hoop they want me to jump through is calling the bank to verify that the account is in good standing and inquire about the rejected requests. I'm fairly certain the bank account is in good standing....will verify of course....but I find it hard to believe that all the people who have posted here, plus countless others that are experiencing the same issue but haven't, are ALL having banking issues in the last 24hrs...I'm more convinced there is a disconnect on the back end between iTunes and Financial institutions...
    I'm not sure I buy in to everything I was told...he also told me he has had several calls on this issue and they were all told to check with their banks. He could not verify that any of his past calls were resolved. Needless to say I'm not 100% believing everything he told me....weak response from Apple support on this issue so far.

  • Please help if anyone can!!!

    I have multiple issues. first, i have a problem on iteration. i am given
    (x,f(x)) and (x + d, f( x + d)), where x ranges from Xmin to Xmax and d = (Xmax - Xmin)/100. Draw the curve f(x) = X^3/100 - x + 10, where x ranges from -10 to 10 in this fashion. And am asked to draw a hundred line segments joining those points.
    I have already figured that the distance d = 10-(-10)/100 which is equal to 0.2. Since i am told to draw 100 line segments, i figured that increasing -10 by .2 will take 100 iterations to get to 10.
    Now my question is how do i use a "for" loop to represent the above statement. I have tried couple of them, but it doesn't seem right. example of the one i tried is:
    let x = 10
    for(i = -10; i < x; i++). I know this is wrong. Please help if anyone can. I will really appreciate and thanks in advance.

    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.Line2D;
    This program draws graphs of curves using iterations
    CS 46A, Fall, 2002
    @author Afam Okeke Section 7
    @version October 6, 2002 Program 6
    public class DrawCubicApplet extends Applet
    public void paint (Graphics g);
    Graphics2D g2 = (Graphics2D)g;
    double xscale = (getWidth() - 1.0) / (XMAX - XMIN);
    double yscale = (getHeight() - 1.0)/ (YMIN - YMAX);
    g2.scale (xscale, yscale);
    g2.translate (-XMIN, -YMIN);
    g2.setStroke (new BasicStroke(0));
    final double Xmax = 10;
    final double Xmin = -10;
    final double Ymax = 15;
    final double Ymin = 5;
    double d = 0.2;
    This is how far i have gotten. Now i don't know how to set up my 'for' loop for the x values. That is, how can i state that from -10 with an increment of 0.2 will take 100 iterations to get to 10. I hope am not confusing you. Below is the question
    Question: Simply draw a hundred line segments joining the points (x,f(x)) and (x + d, f( x + d)), where x ranges from Xmin to Xmax and d = (Xmax - Xmin)/100. Draw the curve f(x) = X^3/100 - x + 10, where x ranges from -10 to 10 in this fashion.

  • IPhoto app stops responding upon launch. Please help how I can fix this problem., iPhoto app stops responding upon launch. Please help how I can fix this problem.

    iPhoto app stops responding upon launch. Please help how I can fix this problem., iPhoto app stops responding upon launch. Please help how I can fix this problem.

    Please clarify:
    What is your iPhoto version?
    And what do you mean by "not responding"? Is iPhoto hanging and showing the spinning beachball?
    Can you launch iPhoto, if you hold down the options key while launching and select or create a different library?

  • I am new to oracle, plz..anybody can explain this query step by step....plz

    Select distinct(a.esal) from employee1 a where &N = (select count(distinct(b.esal)) from employee1 b where a.esal<=b.esal);
    this is the query to find Nth largest & Nth smallest value from the table employee1....but, i am unable to understand how this query works ....plz..anybody can explain this query step by step with example....plz

    Hi,
    Welcome to the forum!
    The first step in understanding any code is to format it so you can easily see what is a sub-query, what the major clauses of each sub-query are, and things like that.
    For example:
    Select distinct (a.esal)
    from   employee1      a
    where  &N     = (       select  count (distinct (b.esal))
                             from      employee1      b
                    where      a.esal           <= b.esal
                );The only thing I have added to the code you posted was whitespace: newlines, tabs and spaces.
    Now it's easy to see that you're doing a query with a scalar sub-query in the WHERE clause.
    It usually makes sense to read complicated queries from the inside out, that is, start with the deepest nested sub-query.
    In this example, that means:
    select  count (distinct (b.esal))
    from     employee1      b
    where     a.esal           <= b.esalWhat does this query do? Unfortunately, it references something (b.esal) from the super-query, so you can't run it by itself, to see what it does. Let's replace that reference with some hard-coded value, just for now, and run it:
    select  count (distinct (b.esal))
    from     employee1      b
    --where     a.esal           <= b.esal     -- This is the original WHERE clause
    where   a.esal           <= 1000     -- For testing only
    ;Experiment with this for a while, and compare it to the values in the employee1 table (or a small test table that resembles employee1). Try different numbers in place of 1000.
    You'll see that the query is counting how many different salaries are lower than, or equal to, a given salary (1000 in the example above).
    When you understand the sub-query, look at the original query again.
    It is testing to see if exactly &N different esals are lower than or equal to the esal on each row, and displaying that esal if it is. (&N is a substitution variable. If you haven't already defined a value for it, SQL*Plus will ask you for a value when you run the query.)
    In other words, it is finding the N-th lowest value of esal.

  • Anyone can compile this program?Duke will be rewarded

    Anyone can help me compile this program..I try debugging a lot of time but it is not working!
    import java.lang.*;
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class ChatApplet extends Applet implements ActionListener,Runnable
    String user;
    String msg;
         public void init() {
              super.init();
              //{{INIT_CONTROLS
              setLayout(new BorderLayout(0,0));
              addNotify();
              resize(518,347);
              setBackground(new Color(12632256));
    msgbox = new java.awt.TextArea("",2,0,TextArea.SCROLLBARS_NONE);
              msgbox.setEditable(false);
    msgbox.disable();
    //msgbox.hide();
              msgbox.reshape(0,0,380,216);
              add(msgbox);
              idbox = new java.awt.TextField();
              idbox.reshape(84,288,284,24);
              add(idbox);
              button1 = new java.awt.Button("EnterRoom");
              button1.reshape(384,288,72,21);
              add(button1);
    list = new java.awt.List();
    //list.TOP_ALIGNMENT();
    //list.disable();
    list = new java.awt.List(5);
    list.add("#Default User"+"\n");
    list.reshape(384,24,128,196);
    list.setFont(new Font("Helvetica", Font.BOLD, 12));
    add(list);
              label2 = new java.awt.Label("Members");
              label2.reshape(396,0,100,19);
              add(label2);
              label1 = new java.awt.Label("UserName");
              label1.reshape(0,288,72,27);
              add(label1);
              textbox = new java.awt.TextField();
              textbox.reshape(84,240,431,44);
              add(textbox);
              label3 = new java.awt.Label("EnterText");
              label3.reshape(0,252,72,25);
              add(label3);
    //uf = new UserFrame();
              button1.addActionListener(this);
    idbox.addActionListener(this);
    textbox.addActionListener(this);
    list.addActionListener(this);
    public void actionPerformed(ActionEvent ae)
              if(ae.getSource()==idbox)
    user = idbox.getText()+"\n";
    list.addItem(user.trim());
    idbox.setText("");
                             msgbox.append(user+" HAS JOINED THE GROUP");
         if(ae.getSource().equals(button1))
    user = idbox.getText()+"\n";
    list.addItem(user.trim());
    idbox.setText("");
                             msgbox.append(user+" HAS JOINED THE GROUP");
    if(ae.getSource().equals(textbox))
    msg = textbox.getText();
    msgbox.append(msg+"\n");
    textbox.setText("");
    if(ae.getSource().equals(list))
    String l = list.getSelectedItem();
                             //uf.setTitle(l);
                             //Frame i[] = uf.getFrames();
                             //uf.setVisible(true);
    public void start()
    if(vt == null)
    vt = new Thread(this,getClass().getName());
    vt.start();
    public void run()
    try{
    for(int i=0;i<10;i++)
    msgbox.append("One stop Java source code - www.globalleafs.com"+"\n");
    msgbox.setForeground(Color.red);
    vt.sleep(30000);
    vt.resume();
    }catch(Exception e){e.printStackTrace();}
         java.awt.TextArea msgbox;
         java.awt.TextField idbox;
         java.awt.Button button1;
    java.awt.List list;
    java.awt.Label label2;
         java.awt.Label label1;
         java.awt.TextField textbox;
         java.awt.Label label3;
    private Thread vt;

    The program compiles over here. It just has some deprecation warnings ...or is that what you wanted debugged?
    Don't use reshape() ...I think in AWT you should now use setBounds();
    Don't use list.addItem(); ...looks like the API steers us to list.add();
    Don't use Thread.resume() ...I don't think there is a replacement (unneccessary?).
    Gee, this program must have ran the chat program in Ford's old model T ... !! (??)

  • If anyone can check this file for me

    Hi!
    Trying to print this ai file I had created. I can't open it now in CS6, CC or 2014? Says I don't have enough memory. (RAM). It is only 1.6mb. I'm running win 7 x64.
    Here it is on dropbox if anyone can opening it and save it say in a standard PDF or more compatible format?
    AI FILE
    When placing it I get this:
    Thank you
    Max

    I can't open the file.
    1) Tells me not enough memory?
    2) placing it in latest PS or AI I get the screen?
    I'll start from scratch, but if the file is okay, I'd rather use that. So if anyone can check it for me. Thanks

  • Question on me51n: who can explain this phenomenon?

    Hi all,
    I am creating a Purchase Requisition via me51n.
    When I fill a 'K' or 'P' in the "acct assignment cat."(A) column in the Header Block. it will automatically bring me to the "Account Assignment" in the Item block, and give the "G/L account no" a default value 400000.
    I dont know why it give me the default value? can someone explain this to me, and where can I set up the configuration for the default value. I tried this in some other system, no such issues.
    Any response will be awarded.
    Thanks and regards,
    Samson

    hi,
    this is because an account modification key is maintained in your account assignemnet.
    please check the same in(OME9)
    say for example if VBR is maintained there check the sane in OBYC where correspondent to that account modification key same GL is maintained which it appears in your PR/PO
    VBR will be there in GBB Transaction key in OBYC
    Edited by: manipal on Dec 28, 2007 9:49 AM

  • Strange: blank in string. Anybody can explain this?

    Hello!
    Look at this. Until now I thougt, I had understood ABAP...
    Output of the following programm:
    1) Strange
    2) Strange
    3) Strange
    4) Strange
    5) Strange
    6) Strange
    Very strange, isn't it?
    ABAPDOCU tells, that strings pay attention to blanks.
    Can anybody explain this?
    REPORT zstrange.
    DATA: stringwithspace TYPE string VALUE 'A B',
          teststring TYPE string,
          blankstring TYPE string VALUE ' ',
          l type i.
    START-OF-SELECTION.
      IF stringwithspace+1(1) = ' '.
        WRITE: / '1) My guess'.
      ELSE.
        WRITE: / '1) Strange'.
      ENDIF.
      IF stringwithspace+1(1) = blankstring.
        WRITE: / '2) guess'.
      ELSE.
        WRITE: / '2) Strange'.
      ENDIF.
      IF stringwithspace+1(1) = ''.
        WRITE: / '3) guess'.
      ELSE.
        WRITE: / '3) Strange'.
      ENDIF.
      teststring = stringwithspace+1(1).
      IF teststring = ' '.
        WRITE: / '4) Guess'.
      ELSE.
        WRITE: / '4) Strange'.
      ENDIF.
      IF teststring = blankstring.
        WRITE: / '5) Guess'.
      ELSE.
        WRITE: / '5) Strange'.
      ENDIF.
      IF teststring = ''.
        WRITE: / '6) guess'.
      ELSE.
        WRITE: / '6) Strange'.
      ENDIF.

    No, thats not strange.
    c variables have always a fixed length, it can not contain "nothing". If there are only spaces in, the c variable is treated as empty/initial.
    Strings can contain nothing, and they can contain spaces. A string containing blanks is not interpreted as empty/initial.
          blankstring TYPE string VALUE ' ',
    What you are doing here is assigning an empty string to the string var blankstring, it does NOT contain a blank.
    Constants encapsulated with apostrophes are treated as c variables. But: constants encapsulated within back quotes will be interpreted as string. Change your code to
          blankstring TYPE string VALUE ` `,
    Take care of that i used back quotes now, not apostrophes, Now the var blankstring contains a blank and the result in that case will change to MY guess.
    Similar the camparison
      IF stringwithspace+1(1) = ' '.
    This is comparing a blank with an empty char and thats why you are getting strange.
    Change this to
      IF stringwithspace+1(1) = ` `.
    and you will get My guess cause now you are comparing a blank with a blank and not a blank with an empty string.
    Hope its now clear.

Maybe you are looking for

  • How do i remove repeated titles on pages

    I just downloaded pages from the mac app store. I have 1 problem. It is that i write the title of my doc in the little square at the top, and it repeates itself on every page. how do i stop this?

  • Filesharing with Windows over Airport Express

    Hi, I have a windows xp network that is set up as follows cable modem -> Linksys BEFSR41 rougter -> Airport the linksys goes off to a few computers and the airport express, now the networks is working beautifuly for internet access, but i am stuck wh

  • Can someone help me with an image

    I would like to know if anyone can copy (Duplacate) this image. I need it for my church, but they dont seem to have a HQ one and its too small. If you can copy the image send me a .PSD file please. Thanks!

  • How do i get videos taken on my iPad to imovie

    I took video on my iPad 2 and downloaded it to iPhoto.  I am trying to get it into iMovie but it will not transfer over.  The videos do not play in iPhoto either.

  • The best casing

    I need the best case for a cheap price for the macbook.. like a sleeve or something just for the macbook.. i have the 13 inch macbook white. please put a link for the site if you can. thanks.