Results 1 to 2 of 2
  1. #1
    parag is offline Member
    Join Date
    Jul 2015
    Posts
    1
    Rep Power
    0

    Default Could anyone tell me the concept used in the line Echo e2=e1;

    public class EchoTestDrive
    {
    public static void main(String [] args)
    {
    Echo e1 = new Echo();
    Echo e2 = new Echo();// the correct answer

    or
    Echo e2=e1;// is the bonus answer


    int x=0;

    while(x<4)
    {
    e1.hello();
    e1.count=e1.count+1; // 4


    if(x==3)
    {
    e2.count = e2.count + 1; //6

    }

    if(x>0)
    {

    e2.count = e2.count + e1.count; //10
    }

    x=x+1;

    }

    System.out.println(e2.count);

    }
    }



    class Echo
    {
    int count = 0;

    void hello()
    {
    System.out.println("hellooooo...");
    }
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Could anyone tell me the concept used in the line Echo e2=e1;

    Echo e2=e1
    That statement defines a variable: e2 and assigns it a value: e1.

    Please edit your post and wrap the code in code tags.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Programming an echo to a sound
    By od11kd in forum New To Java
    Replies: 2
    Last Post: 11-11-2012, 10:09 PM
  2. Replies: 0
    Last Post: 07-20-2008, 03:58 PM
  3. An echo server using UDP sockets
    By Java Tip in forum java.net
    Replies: 0
    Last Post: 04-07-2008, 08:09 PM
  4. echo of pwd
    By jeffpoulsen in forum New To Java
    Replies: 3
    Last Post: 12-04-2007, 03:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •