answersLogoWhite

0

Why does not use pointer in java?

Updated: 8/10/2023
User Avatar

Wiki User

12y ago

Best Answer

You do not use pointers in Java because the language designers decided to abstract memory management to a higher level in Java than in C. The reason for this is that it is easy to make mistakes using pointers and other lower level memory management techniques. These mistakes can lead to bugs. hard to read code, memory leaks that waste system resources, and security issues. Instead for the most part Java takes care of memory management for the user who can instead specify behavior though the object oriented techniques that are safer and easier to understand. The downside is that the programmers lose some control and flexibility in using memory. Also, programs using Java take a small performance hit in some cases because of the extra work Java has to do to manage memory itself.

They are, however in Java they are called references.

User Avatar

Wiki User

16y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

Pointers are a concept in C wherein the programmer can access the system memory and process it. Pointers are considered the most complex as well as confusing part of the C Programming language.

almost all C programs using pointers had hours of time spent by the programmers to sort out errors they induced in their code using pointers.

So Java conveniently avoided pointers :)

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Java does not support multiple inheritance because of the Diamond problem came to the program...

for example if a method sum() is coming from A class and the same sum() is coming from B class...so which one will be considered there...and the purpose of interfaces is not to support multiple inheritance ,but this is different...

Pointers are supported by java internally,,,and these are pointers to the pointers...these are further mapped with the reference variables for the security purposes.so that we can not reach directly to the location and do the changes to the location data...

so in java to reach an location is reference variables....

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

The appropriate term would be "Pointers were avoided when Java was created"

The C language gives access to its memory to the developer which gives great powers to the programmer but its like giving a dynamite. Pointers caused more harm than good to the developers world over while using the C language. Any C developer you talk to would have a story to narrate regarding his tough experience with pointers. Hence the team that created the Java language took a decision to avoid the concept of Pointers from this new language they were creating.

Hence Java doesnt have pointers.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

They are, however in Java they are called references.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

In Java Garbage Collection is present. Garbage collector job is to clear the space which is not in use.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

No. Java objects are not pointers. Java does not support the pointers concept. You cannot access the memory location of the java objects.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why does not use pointer in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What you use in case of pointer in java?

Java does not have pointers


What is pointer in java?

There is no concept similar to pointers in Java. Pointers are a feature in C programming using which a programmer can access the memory. This was the cause of major catastrophic programming bugs. The creators of Java excluded this feature just to avoid such catastrophic bugs.


Why java is more preferable than c plus plus?

Becuse there r no use of pointer in java. So we can't think about memory manipulation..............


In which language pointer concept is not used?

Java


How does java secures the code?

java is securejava uses the pointer internally. programer cannot use the pointer in our program explicitly. due to use of pointers information may be lostex-int *p;int a=56;int b=98;p=&a;p=&b;in above program first time pointer points the a value and in next line p points the b value, so here a information is lost


Why do java consider pointer as dangerous?

programmers are always confused with pointers


Java null pointer exceptions?

A null pointer exception in java comes when you are trying to perform any action on an object that isnt initialized/has a value i.e., is a NULL Value Ex: private String s; //declare a string if(s.equals("test")){ //do something.. } You will get a null pointer in the if condition because you are checking a value that is null which is not allowed..


How we can get address of variables in Java as pointer variables in C?

At any given point of time you cann't get the address of a variables of java program. This is meant for security purpose only.


Dangling reference in java?

I think you're referring to the C/C++ concept of "dangling pointers." This is when you allocate some memory to a pointer, then deallocate that memory, but don't change the pointer. This causes any attempted use of the pointer to return an unused memory address. There is no such concept in Java, since the programmer has little to no control over how memory is allocated or freed. The closest thing I can think of is if you're using a class such as a Reader, in which you can close the object (Reader.close()) and then still have a reference to it. But in this case (and other similar cases) attempting to use the Reader further will result in an IOException being thrown.


Can you use pointers in java?

Java does not support Pointers and hence you cannot use it in Java.


Can NullPointerException be used with ArithmaticException using throws keyword in java?

No. You cannot throw or catch Null pointer exceptions


Why you use an array of pointer to pointer?

because u freakin can