no pointer in java
2024-08-30 02:27:57
Why there are no pointers in Java?
- In Java there are references instead of pointers. These references point to objects in memory. But there is no direct access to these memory locations. JVM is free to move the objects within VM memory.
- The absence of pointers helps Java in managing memory and garbage collection effectively. Also it provides developers with convenience of not getting worried about memory allocation and deallocation.
If there are no pointers in Java, then why do we get NullPointerException?
- In Java, the pointer equivalent is Object reference. When we use a . it points to object reference. So JVM uses pointers but programmers only see object references.
- In case an object reference points to null object, and we try to access a method or member variable on it, then we get NullPointerException.
最新文章
- 深入剖析tomcat 笔记——第8章 载入器
- 【温故Delphi】之VCL消息机制小结
- Html与CSS快速入门02-HTML基础应用
- Spring mvc web.xml中 urlpatten的配置问题
- [充电]C++ string字符串替换
- 如何在PHP里面连接数据库
- 不知还有人遇到这个问题没有:数据库 'xxx' 的版本为 706,无法打开。此服务器支持 661 版及更低版本。不支持降级路径。
- NSURLConnection、NSURLSession
- C#调用webservers实现天气预报
- sql加强练习
- hdoj 1166 敌兵布阵(树状数组)
- 【知识整理】这可能是RxJava 2.x 最好的入门教程(一)
- 区分javascript中的toString(),toLocaleString(),valueOf()方法
- go语言关于值类型和引用类型
- Spring AOP Capabilities ang goals
- 通过微信公众号API复制公众号自定义菜单同时增加子菜单方法
- 【XSY1602】安全网络 树形DP 数学
- IP地址在mysql的存储(IP地址和int的转换)
- Ubuntu下解决MySQL自启动,chkconfig list 全部off 情况
- Bigining