Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: why is this there and what does it do?

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default why is this there and what does it do?

    public class Sprite {
    	/** The image to be drawn for this sprite */
    	private Image image;
     
    	/**
    	 * Create a new sprite based on an image
    	 * 
    	 * @param image The image that is this sprite
    	 */
    	public Sprite(Image image) {
    		this.image = image;
    	}

    why is there two Images? what does the first do and what does the second do? im confused and ive seen this with the word game as well.

    i've noticed that the capitalization are different but i don't understand the purpose. if any one could try to elaborate that would be stupendous. =)

  2. #2
    Junior Member
    Join Date
    Mar 2010
    Location
    Mauritius
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: why is this there and what does it do?

    Hi cejay

    By two images, I am guessing you are referring to the following lines
     public Sprite(Image image)
    The first Image is the referring to the class Image. The second is just a variable name. The following also works
    public Sprite(Image img)
    It just means that the variable image is an object of the class Image

    Cheers
    (prit4u.wordpress.com)
    Last edited by Wanderer; March 2nd, 2010 at 04:46 AM.

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: why is this there and what does it do?

    oh! thats why it is lower case on the second one! thanks man =). that cleared some stuff up lol.