001 /** 002 * Make an instance of a class in another package and try to access a protected 003 * field. 004 * 005 * @author Kristian Torp, torp (at) cs (dot) aau (dot) dk 006 * @version 1.0 007 */ 008 public class UseMyPackage { 009 public static void main(String arg[]) { 010 // creating objects works fine 011 MyPackage.Exercise6_15 cl = new MyPackage.Exercise6_15(); 012 System.out.println(cl); 013 // try to access a protected variable outside the package 014 // results in cimpile error 015 //cl.x = 15; 016 } 017 }