Results 1 to 2 of 2
  1. #1
    Army is offline Senior Member
    Join Date
    Jan 2012
    Posts
    147
    Rep Power
    0

    Default What is the significance of THIS?

    I need to know the significance of the keyword this. It seems to me like it does nothing, since I get no errors when I run it without this.

    Java Code:
    package OOP;
    class rect{
    	int width;
    	int height;
    	int depth;
    	
    		void box(int h, int w, int d){
    			this.width = w;
    			this.height = h;
    			this.depth = d;
    		}
    		void result(){
    			System.out.println(height);
    			System.out.println(width);
    			System.out.println(depth);
    			System.out.println(depth * width * height);
    		}
    }
    public class Rectangle {
    	public static void main(String [] args){
    		rect objRect = new rect();
    		objRect.box(24, 10, 5);
    		objRect.result();
    	}
    
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,969
    Rep Power
    8

    Default Re: What is the significance of THIS?

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Significance of the main method in a java program
    By Dreaming in forum New To Java
    Replies: 10
    Last Post: 01-29-2012, 03:21 AM
  2. significance of static variables and methods
    By imran_khan in forum New To Java
    Replies: 4
    Last Post: 08-02-2007, 09:52 AM

Posting Permissions

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