Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error message: not public in java. can't be accessed from outside package

 
Maureen Charlton
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MainProgram.java:120: java.util.HashMap.Entry is not public in java.
; cannot be accessed from outside package
HashMap.Entry entry = (HashMap.Entry)iterator2.next( );

Is anyone able to explain to me what this is actually saying?
 
Alain Boucher
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hashmap.class:

public class HashMap extends AbstractMap implements Map, Cloneable,
java.io.Serializable {
/**
* The hash table data.
*/
private transient Entry table[];

etc...

Entry is private... you cannot use Hashmap.Entry because you are not in a method in the Hashmap class, this field is private to that class

The Entry class is a Inner class of HashMap, so it is for internal use only (because of private)

Only use public method to get your data
 
Maureen Charlton
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alan - thanks for this. Much appreciated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic