A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

can any one explain 'THIS' KEY WORD IN JAVA..????

  • This Question is Closed
  1. Owlfred
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hoot! You just asked your first question! Hang tight while I find people to answer it for you. You can thank people who give you good answers by clicking the 'Good Answer' button on the right!

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    NO ONE INTRESTED IN JAVA...

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    @nitin: i am not :D

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    sometimes a method wil need to refer the object that invoked it.then 'this' keyword is used.i.e.,'this' is always a reference to the object that invoked it.

    1 Attachment
  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i think this use to define a cammand

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    The keyword this is useful when you need to refer to instance of the class from its method. The keyword helps us to avoid name conflicts. As we can see in the program that we have declare the name of instance variable and local variables same. Now to avoid the confliction between them we use this keyword. Here, this section provides you an example with the complete code of the program for the illustration of how to what is this keyword and how to use it. In the example, this.length and this.breadth refers to the instance variable length and breadth while length and breadth refers to the arguments passed in the method. We have made a program over this. After going through it you can better understand. Here is the code of the program: class Rectangle{ int length,breadth; void show(int length,int breadth){ this.length=length; this.breadth=breadth; } int calculate(){ return(length*breadth); } } public class UseOfThisOperator{ public static void main(String[] args){ Rectangle rectangle=new Rectangle(); rectangle.show(5,6); int area = rectangle.calculate(); System.out.println("The area of a Rectangle is : " + area); } }

  7. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.