Topic: 求教:Java的访问控制问题!? |
Print this page |
1.求教:Java的访问控制问题!? | Copy to clipboard |
Posted by: xieruibo Posted on: 2005-01-06 13:52 有这样一段代码: public class StackLinked{ private Node Top; ..... ..... public Node pop(){ if(isEmpty()) throw new NoSuchElementException("The stack is empty!"); else{ Node item = top; top = top.next; //............(1) item = null; } } ..... ..... private class Node { private Object data; //.............(2) private Node next; //.............(3) Node(Object data){ this(data, null) } Node(Object data, Node next){ this.data = data; this.next = next; } } 请问一下:在(2)、(3)处将data,next声明为private,为什么(1)处 能直接访问top的next属性!?是不是与Node定义在 Stack里有关? 请指点一下,谢谢! |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |