Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 12-06-2010, 11:47 AM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Jun 2010
Posts: 1
Lightbulb core java issue:alternative for super keyword in static method


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
}
}
rahulchand is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 12-06-2010, 03:41 PM   #2 (permalink)
Apprentice
 
prttal's Avatar
 
Join Date: May 2010
Posts: 55
Default Re: core java issue:alternative for super keyword in static method

You may create another non-static function like
public int getVal()
{
//code here
}
prttal is offline   Reply With Quote
Old 17-06-2010, 07:06 PM   #3 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: core java issue:alternative for super keyword in static method

Can't you do like
Code:
System.out.println("--"+A.x);
?
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
decide between intel core2 duo or phenom amd quad core Dr Mohit Hardware Q&A 3 28-05-2010 06:57 PM
Running swf files from Java channabasanna Programming 0 03-03-2010 05:53 PM
[suggest] cheap dual sim java phone phuchungbhutia Buying Advice 2 12-02-2010 05:14 PM
Valuable Sites for Techies sreedevi Tutorials 15 04-10-2005 10:35 PM
Intel Pentium D 2.80 Ghz reviewed (dual core) mohit CPU / Motherboards 1 27-05-2005 02:11 PM

 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:19 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2