Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


this, and ovverride filter_list
Author
Message
this, and ovverride #1
guys, how do u use >this< and >Override<???

Reply

RE: this, and ovverride #2
Could you tell the language?
I think it's probably Java or C#.


Reply

RE: this, and ovverride #3
(10-09-2013, 05:06 AM)Slarek Wrote: Could you tell the language?
I think it's probably Java or C#.

Since he has posted this in the java sub forum so he must be referring to java.



@rexist

@Override annotation was added in JDK 1.5 and it is used to instruct compiler that method annotated with @Override is an overridden method from super class or an interface. @Override is particularly useful while overriding methods that accept Object as parameter just like equals, compareTo of Comparable interfaces or hashCode() method etc.

Take for an example the following :-

Code:
public class HC{
    private String name;

    public boolean equals(HC username){
        return name.equals(HC.username);
    }
}

In the above code we are attempting to override equals() method, but instead of overriding, its actually overloaded method. This error escape from compiler and not even detected on runtime by any Exception and it’s very hard to detect. @Override annotation in Java prevents this category of mistake. When we put @Override annotation above equals method than compiler will verify if this method actually overrides a super class or an interface method or not. if its not then it throw compilation error something like "method does not override or implement a method from a super type". @Override saves you a lot of debugging. Also using @Override is a good programming practice. From Java 6 onwards you can use @Override annotation while implementing interface method as well.

Here are some examples :- http://javarevisited.blogspot.sg/2011/02...-java.html



this

http://docs.oracle.com/javase/tutorial/j...iskey.html

http://www.javatpoint.com/this-keyword


Read the above and its enough. The second link has examples study those.


By the way these questions can be easily googled.







[Image: OilyCostlyEwe.gif]

Reply

RE: this, and ovverride #4
thanks a lot,,,,I'll figure out the rest.

Reply

RE: this, and ovverride #5
thanks a lot,,,,I'll figure out the rest.

Reply

RE: this, and ovverride #6
@Psycho_Coder
Well that was rather embarrassing. I couldn't just check the sub forum:Grin:


Reply

RE: this, and ovverride #7
@Psycho_Coder
Well that was rather embarrassing. I couldn't just check the sub forum:Grin:


Reply







Users browsing this thread: 2 Guest(s)