java可以使用指针吗_java真的有指针吗?

在内部,对象的引用被实现为指针。虽然没有指针算法......

C++有指针,因为它是作为C的超集构建的,它有指针。 C有指针,因为它是在60年代设计的。那时计算机的内存非常少,指针允许执行字符串,数组和参数传递。

这是白皮书The Java Language Environment的摘录:

2.2.9 No More Pointers

Most studies agree that pointers are one of the primary features that

enable programmers to inject bugs into their code. Given that

structures are gone, and arrays and strings are objects, the need for

pointers to these constructs goes away. Thus, Java has no pointer data

types. Any task that would require arrays, structures, and pointers in

C can be more easily and reliably performed by declaring objects and

arrays of objects. Instead of complex pointer manipulation on array

pointers, you access arrays by their arithmetic indices. The Java

run-time system checks all array indexing to ensure indices are within

the bounds of the array.

由于指针不正确,你不再有悬空指针和内存垃圾,因为Java中没有指针。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值