Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

Debug the error !

Thread view: 
Gaurav - 01 Dec 2005 07:43 GMT
Hi .. kindly tell me the error in the following code

package test1;
public class Test1 {
static int x = 42;
}

package test2;
public class Test2 extends test1.Test1 {
public static void main(String args[]) {
System.out.println("x="+x); } }
Roedy Green - 01 Dec 2005 08:12 GMT
>Hi .. kindly tell me the error in the following code
Please tell what the problem is, quoting the error message verbatim.
It is annoying to be given guessing games.  Teachers give students
guessing games, not the reverse.

Presumably your problem is that x is default rather than protected
scope, thus classes in package test2 can't see it.
see http://mindprod.com/jgloss/scope.html

>package test1;
>public class Test1 {
[quoted text clipped - 5 lines]
>public static void main(String args[]) {
>System.out.println("x="+x); } }
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.