I am new to Java.I can't understand the meaning behind "hiding" and "overriding". Both do the same job. For example: Look the following program that I found on StackOverflow
import java.util.*;
import java.lang.*;
import java.io.*;
public class Apples {
public static void main(String[] args) {
Foo.method();
Bar.method();
}
}
class Foo {
public static void method() {
System.out.println("in Foo");
}
}
class Bar extends Foo {
public static void method() {
System.out.println("in Bar");
}
}
In above program, the code
Bar.method();
overwrites the class Foo static method. Then how it differs from overriding?