Results 1 to 3 of 3
  1. #1
    MW130 is offline Senior Member
    Join Date
    Jan 2013
    Rep Power

    Default What does setting an object equal to another do?

    I've seen this done in code:
    for example,
    Java Code:
    BufferedImageOp op = new ConvolveOp()
    what does this mean? Is it creating an object of convolveOP for the BufferedImage class?

    What does it mean when you set an object from one class equal to another?


  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: What does setting an object equal to another do?

    BufferedImageOp op = new ConvolveOp();

    The GREEN part defines a variable that can have the address of a BufferedImageOp object
    The BLUE part creates a new instance of a ConvolveOp() object and returns its address
    The RED part assigns the value on the right to the variable on the left of the =

    Interesting question from an OP with over 300 posts.
    Last edited by Norm; 03-05-2014 at 06:35 PM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: What does setting an object equal to another do?

    Did you check out the API documentation?

    BufferedImageOP is an interface.
    ConvolveOP is a class that implements the interface.
    So it is perfectly valid to assign an instance of ConvolveOp to any one of its implemented interface types.

    In this case, it is BufferedImageOP.

    This is no different that assigning an instance of ArrayList<T> to a type of List<T>.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. help with not equal to operator !=
    By manowar689 in forum New To Java
    Replies: 9
    Last Post: 06-15-2010, 12:10 AM
  2. equal() method
    By need_helpp in forum New To Java
    Replies: 3
    Last Post: 03-09-2010, 06:57 PM
  3. Set an Object Equal to Another Object
    By xpngamer in forum New To Java
    Replies: 5
    Last Post: 04-27-2009, 11:38 AM
  4. How setting an Object to null help Garbage Collection?
    By piyu.sha in forum Advanced Java
    Replies: 3
    Last Post: 10-06-2008, 07:35 AM
  5. Object Reflection: Setting value
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:13 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