作者chen1025 (小陈)
看板java
标题Re: [问题] java不支援pointer
时间Sat Apr 14 20:53:11 2012
小弟的浅见以为:
Java虽然没有支援pointer
可以任意指定记忆体位置作计算
而类别实例的名子,本身就是记忆体位置
是可以实作linked list
大概会是这样:
Class List{
int data;
//前一笔资料
List front=null;
//後一笔资料
List back=null;
...
//写List的方法
.....
}
※ 引述《wsx02 ()》之铭言:
: Java is a programming language derived much of its syntax from C and C++.
: Different from C and C++, Java does not support pointer arithmetic.
: 1. Please explain the reasons behind such design. (Hint: You might need to use
: "Stacks" in your answer)
: 2. Without pointer arithmetic ability, can you still implement linked list
: in Java?
: 请问第一题应该怎麽回答比较好呢?
: 第二题我会回答有提供reference来实作linked list 不知道这样可以吗?
: 谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.119.157.8
1F:→ calais007:Java有pointer,但不support pointer运算,你不能拿 04/15 00:21
2F:→ calais007:pointer作+,-,++,--,&,*运算,也不能强制cast一块记忆体 04/15 00:24
3F:→ calais007:它不希望Programmer管理记忆体,而是VM管理,可能是为了GC 04/15 00:26