|
-
Sep 26th, 2004, 01:33 PM
#1
Thread Starter
Hyperactive Member
Problem accessing an object in a different package...
Hello everyone, i'm having problems accessing an Intger Object orginally created in MIS class. I'm suppose to, "3.Implement the CE class so it can print out the value mis_y originally stored in the MIS class. "
This is the structure of all my classes i've created.
I have two packages,
Gannon and Behrend
Inside the Gannon package I have the following classes:
CIS
MIS
I also have an inferface called Department;
CIS and MIS both implement the Department inferface
Inside the Behrend package I have the following classes:
SE
CE
EE
I also have an interface called School;
SE,CE, and EE all implement the School interface.
CE also extends the MIS class so I can access a protected data member, mis_y;
mis_y is protected in the MIS class.
Code:
package Gannon;
public class MIS implements Department {
public MIS() {
}
Integer mis_x = new Integer(300);
protected Integer mis_y = new Integer(500);
private Integer mis_z;
Here is my code to the CE class:
Code:
package Behrend;
import Gannon.MIS;
public class CE extends MIS implements School {
public CE() {
}
public static void main(String args[])
{
MIS b = new MIS();
System.out.println("mis_y: "+ b.mis_y );
}
When i run this file, i get the following error:
"CE.java": mis_y has protected access in Gannon.MIS at line 24, column 37
Which makes no sense because protected data members are accessible to a different package subclass.
Any idea's what i did wrong?
Thanks!
Last edited by Dilenger4; Oct 7th, 2004 at 05:09 PM.
C¤ry Sanchez
Computer Science/Engineering
@ Penn State
IBM.zSeries Intern
Mandriva 2007
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|