+ 13

Why java has not the concept of pointers?

14th Sep 2017, 2:57 AM
Gourav raghuwanshi
Gourav raghuwanshi - avatar
16 Respuestas
+ 4
Java was created to be portable and easy to develop. Pointers are dangerous if you don't know what you are doing. Since they never claimed to be a language for fast performance programs, they hid the concept of pointers under a layer of abstraction.
14th Sep 2017, 6:34 PM
Denis Felipe
Denis Felipe - avatar
+ 2
Java is platform independent. So if we use pointers the address of the variable varies in different machines. Thus using pointers becomes invalid and provides different result in different machine. Also java provides security without the use of pointers.
14th Sep 2017, 6:05 PM
Archana.R
Archana.R - avatar
+ 2
For security purpose pointers are not in java. As if there would be pointers then accessing main memory becomes easier( as pointers points to the main memory) for hackers and they could hack important information.
14th Sep 2017, 6:10 PM
kanishka
kanishka - avatar
+ 2
due to more sucurity reasons
15th Sep 2017, 4:45 AM
Rameshvar Dayal
Rameshvar Dayal - avatar
+ 2
since Java is OOP so we can access all the members with the help of object reference so we do not need point.
15th Sep 2017, 10:53 AM
Rahul Kumar
Rahul Kumar - avatar
+ 1
for memory management and also due to the security concerns... pointers let programs to access the memory directly and change the contents of the memory... the memory accessed here can be used by other process.. that may cause serious damage to that process
14th Sep 2017, 6:02 PM
Balaji Sridharan
Balaji Sridharan - avatar
+ 1
@Piyush Manglani, your explanation is misleading. Pointers are very good for performance and to save memory if you know what you are doing. They are a very powerful tool. C++ expects the programmer to know what they are doing, while Java expects them to be prone to mistakes.
15th Sep 2017, 1:45 PM
Denis Felipe
Denis Felipe - avatar
+ 1
I was just pointing out that the reason is not to save memory from empty pointers, because Java still uses the same memory from pointers, but with extra memory and processing to hide them from programmers. All variables, are deallocated manually or when they go out of scope, but Java often uses more memory because programmers don't control when that deallocation is done.
15th Sep 2017, 2:26 PM
Denis Felipe
Denis Felipe - avatar
+ 1
because Java is secure language pointer concept loss security
16th Sep 2017, 6:28 AM
Neeraj Kumar
Neeraj Kumar - avatar
+ 1
Java does not have the concept of pointers primarily to enhance security and simplify memory management. Pointers in languages like C and C++ allow direct manipulation of memory addresses, which can lead to memory-related bugs like null pointer dereferences and buffer overflows, making programs error-prone and potentially insecure. Java, on the other hand, employs a managed memory model through automatic memory management (garbage collection), which abstracts away memory addresses and allows developers to focus on writing safer, more reliable code. This design choice makes Java less susceptible to memory-related vulnerabilities and contributes to its reputation as a secure and developer-friendly language. https://net-informations.com/java/cjava/pointers.htm
11th Sep 2023, 7:14 AM
evanbung
0
java has no pointers to prevent memory leak. explaing the concept : have anybody heard about the linked list in c++ what us the function of linked list it is used to save address of the next no. and there are types of linked list i am not mentioning them here.lets come to point when a linked list is used and is not in use any more the pointers which were used to allocate memory address become empty and this waste of memory.to prevent this memory waste pointers are not used in java and also for some security reasons pointers are not used. i hope it helps.
15th Sep 2017, 12:21 PM
Piyush Manglani
Piyush Manglani - avatar
0
@Denis Felipe sorry if i offended you but i was talking about java. i told why java dont have pointers.java uses refrence variables by using keyword NEW and java also had pointers but not implicit pointers. i am not misleading just sharing what i know and i do know what i am doing and yes c++ is a powerful language. thank you for correcting me denis, appreciate it .
15th Sep 2017, 1:50 PM
Piyush Manglani
Piyush Manglani - avatar
0
yes i know in java we dont have to clear memory by using any keyword the work is done by garbage collector. but i learned something from you thankyou
15th Sep 2017, 3:56 PM
Piyush Manglani
Piyush Manglani - avatar
0
It is not a critic to you, I was just trying to help. You are welcome. =)
15th Sep 2017, 3:58 PM
Denis Felipe
Denis Felipe - avatar
0
yes you helped me denis.
15th Sep 2017, 4:00 PM
Piyush Manglani
Piyush Manglani - avatar