DIGIT-ARC read-only archive · snapshot: July 23, 2026

core java issue:alternative for super keyword in static method

3 posts · originally from https://geek.digit.in/community/threads/core-java-issue-alternative-for-super-keyword-in-static-method.128129/

R
rahulchand Original post #1
Jun 12, 2010 at 11:47 AM
as you know java doesn't allow the use of super keyword inside a static method,is their any way to access the data member of super class having same name and type as that of a local data member in main method without creating an object reference.

class A
{
static int x=10;//access to 10 without object reference
}
class B extends A
{
public static void main(String []rc)
{
int x=11;
System.out.println("--"+x);//prints 11
}
}
prttal
prttal #2
Jun 12, 2010 at 3:41 PM
You may create another non-static function like
public int getVal()
{
//code here
}
Garbage
Garbage #3
Jun 17, 2010 at 7:06 PM
Can't you do like
Code:
System.out.println("--"+A.x);
? :p