-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
6-pool
-
generic
-
generic
http://download.oracle.com/javase/tutorial/java/data/comparestrings.html
I would like to draw your attention to the description for "compareTo". "Compares two strings lexicographically" would have completely put me off had I not already covered compareTo in college. Can this not be broken down into simple language? It is hard enough learning an object oriented language without needing a copy of the Oxford English Dictionary as well :)
Also on the page http://download.oracle.com/javase/tutorial/java/IandI/override.html
"If a subclass defines a class method with the same signature as a class method in the superclass, the method in the subclass hides the one in the superclass.
The distinction between hiding and overriding has important implications. The version of the overridden method that gets invoked is the one in the subclass. The version of the hidden method that gets invoked depends on whether it is invoked from the superclass or the subclass. Let's look at an example that contains two classes. The first is Animal, which contains one instance method and one class method:
public class Animal {
public static void testClassMethod() {
System.out.println("The class method in Animal.");
}
public void testInstanceMethod() {
System.out.println("The instance method in Animal.");
}
}
The second class, a subclass of Animal, is called Cat:
public class Cat extends Animal {
public static void testClassMethod() {
System.out.println("The class method in Cat.");
}
public void testInstanceMethod() {
System.out.println("The instance method in Cat.");
}
public static void main(String[] args) {
Cat myCat = new Cat();
Animal myAnimal = myCat;
Animal.testClassMethod();
myAnimal.testInstanceMethod();
}
}
The Cat class overrides the instance method in Animal and hides the class method in Animal. The mainmethod in this class creates an instance of Cat and calls testClassMethod() on the class andtestInstanceMethod() on the instance.
The output from this program is as follows:
The class method in Animal.
The instance method in Cat.
As promised, the version of the hidden method that gets invoked is the one in the superclass, and the version of the overridden method that gets invoked is the one in the subclass."
I believe that this section completely overcomplicates method hiding. Overriding is very clear to me but the explanation of hiding methods seems to trail off into code which is not very well explained. I got help on the forums @ Daniweb - http://www.daniweb.com/forums/thread303479.html
I believe this page would be greatly simplified with smaller individual examples of overriding methods and hiding methods rather than lumping both into one code segment. It seems simple and sensible to me now a week or two later after reading the tutorial but I remember having great difficulty on my first attempt and, after all, the site is aimed at people just learning the language.
I would like to draw your attention to the description for "compareTo". "Compares two strings lexicographically" would have completely put me off had I not already covered compareTo in college. Can this not be broken down into simple language? It is hard enough learning an object oriented language without needing a copy of the Oxford English Dictionary as well :)
Also on the page http://download.oracle.com/javase/tutorial/java/IandI/override.html
"If a subclass defines a class method with the same signature as a class method in the superclass, the method in the subclass hides the one in the superclass.
The distinction between hiding and overriding has important implications. The version of the overridden method that gets invoked is the one in the subclass. The version of the hidden method that gets invoked depends on whether it is invoked from the superclass or the subclass. Let's look at an example that contains two classes. The first is Animal, which contains one instance method and one class method:
public class Animal {
public static void testClassMethod() {
System.out.println("The class method in Animal.");
}
public void testInstanceMethod() {
System.out.println("The instance method in Animal.");
}
}
The second class, a subclass of Animal, is called Cat:
public class Cat extends Animal {
public static void testClassMethod() {
System.out.println("The class method in Cat.");
}
public void testInstanceMethod() {
System.out.println("The instance method in Cat.");
}
public static void main(String[] args) {
Cat myCat = new Cat();
Animal myAnimal = myCat;
Animal.testClassMethod();
myAnimal.testInstanceMethod();
}
}
The Cat class overrides the instance method in Animal and hides the class method in Animal. The mainmethod in this class creates an instance of Cat and calls testClassMethod() on the class andtestInstanceMethod() on the instance.
The output from this program is as follows:
The class method in Animal.
The instance method in Cat.
As promised, the version of the hidden method that gets invoked is the one in the superclass, and the version of the overridden method that gets invoked is the one in the subclass."
I believe that this section completely overcomplicates method hiding. Overriding is very clear to me but the explanation of hiding methods seems to trail off into code which is not very well explained. I got help on the forums @ Daniweb - http://www.daniweb.com/forums/thread303479.html
I believe this page would be greatly simplified with smaller individual examples of overriding methods and hiding methods rather than lumping both into one code segment. It seems simple and sensible to me now a week or two later after reading the tutorial but I remember having great difficulty on my first attempt and, after all, the site is aimed at people just learning the language.