+14

Why java has not the concept of pointers?

9/14/2017 2:57:40 AM

Gourav raghuwanshi

16 Answers

New Answer

+23

Memory access via pointer arithmetic - this is fundamentally unsafe. Java has a robust security model and disallows pointer arithmetic for this reason. Java does have reference to objects, it just doesn't call them pointers. Any normal object reference works like a pointer would.

+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.

+3

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.

+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.

+2

due to more sucurity reasons

+2

since Java is OOP so we can access all the members with the help of object reference so we do not need point.

+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

+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.

+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.

+1

because Java is secure language pointer concept loss security

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.

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 .

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

0

It is not a critic to you, I was just trying to help. You are welcome. =)

0

yes you helped me denis.