Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes can we overriding static method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

can we overriding static method

Pawan M

Joined: Feb 23, 2008
Posts: 3
I was reading queries posted by other so i got one doubt due to following sentences that
"You can "override" a non-final static method, although this is actually redefining it and hiding the original method."

but what i know that we can not override static method.
Am i correct or not,please clear my doubt? i have also created one program
class OverridenStaticMeth {

static void printValue() {

System.out.println("Overriden Meth");


public class OverrideStaticMeth extends OverridenStaticMeth {

public static void main(String[] args) {

OverridenStaticMeth osm = new OverrideStaticMeth();



static void printValue() {

System.out.println("Overriding Meth");

but i am getting output-Overriden Meth
so where its overriding?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60774

"Pawan M", please check your private messages for an important administrative matter.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60774

Please take the time to choose the correct forum for your posts. This forum is for questions on Tomcat.

This post has been moved to a more appropriate forum.
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
It turns out we've already got a copy of this, here. Pawan, please don't post the same question in more than one forum, as it wastes people's time when they respond to one without realizing it's been answered elsewhere.

"I'm not back." - Bill Harding, Twister
It is sorta covered in the JavaRanch Style Guide.
subject: can we overriding static method
Similar Threads
Generics doubt
Can we override static method
Small OO doubt
doubt var arg
Doubt in Overloading