Forum Stats

  • 3,722,787 Users
  • 2,244,413 Discussions


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is there an error in the example?

User_XXEJS Member Posts: 1 Green Ribbon

I'm watching the "introduction to Java, part 3" video in the "Java SE: Programming Complete" course and at minute 11:03 an object called "x" is accessing a protected field in other package. This is the line of code: x.y2;

The thing is, that is not possible because field y2 is protected and the class X can't extend itself and is not in the same package. The example would work if the object "x" was an object of the class Y.

I'm am right and the slide is wrong? or is the the other way around? I tried in the IDE and the example doesn't work.


Sign In or Register to comment.