Why JAVA does not have POINTERS?

Questions by Chithambaram.P   answers by Chithambaram.P

Showing Answers 1 - 15 of 15 Answers

jitender

  • Jan 23rd, 2007
 

because with pointers we can access memory location directly which should'nt be allowed in java due to security reasons

  Was this answer useful?  Yes

ramki

  • Jan 24th, 2007
 

hey java doesnt support pointers concept becaz , this concept deals with the memory allocation conecpts . so the concept of pointers may effect our system memory.and the memory may getsome problems.thats why this concept of pointers is not supported by java.

  Was this answer useful?  Yes

Sudy

  • Jan 24th, 2007
 

Well, to start of with lets confine our understanding about Java with pointers in two catagories:1) Use of pointers by java programmers2) Use of pointers by java users (we)1) Use of pointers by java programmers: The java programmers themseleves have used pointers.. The very simple example is the "new" keyword which deals with memory allocation. Memory allocation for an object is done through new keyword. The size of the memory that would be allocated would depend on the datamembers(variables at class level) in the class to which object belongs. That shows new keyword is also dynamic. No doubt, to achieve such a feat in RAM which is always randomly accessed, one has to use pointers!! Othewise it would not be possible to get back the value stored in the variable as the java system will not be aware about the variable address.But, thats not the case. U still very much get back the value of the variable when required. Now think, would this be possible without the use of pointers? (by programmers/makers of java)2) Use of pointers by java users (we): Yes, java does not allow us to use pointers. Couple of reasons are already mentioned as I see, but there are few more facts. a. Pointers increases code complexity b. But the most imp reason that I see is, due to a firewall. Let me explain:JVM (Java Virtual Machine) has an inbuilt software firewall that deals with net security side of Java. (Untrusted applets and things like that). The same firewall can easily be breached if we use pointers. It would be as good as having a 8 feet thick concrete wall around your house with no gate!!But, lets not forget that still "call by refrence" in java is possible. Refrencing is allowing at Object level and not at variable level. (U can't create a refrence variable(pointer) but u can always create a refrence object.That's all I know.

  Was this answer useful?  Yes

Guest

  • Jan 30th, 2007
 

Study said in Java "Call By Refrence " is possible . Thats not the fact .When u pass an object to a method, it is copied at the recieving end. So now two object points to same memory area. Class A { public method(B Ab){//}}now if u call method like B b= new AB();A a = new A(); a.method( b);It doesnt mean b is passed by refrence to Abcz in method if u call some thing like Ab = new B();Ab now points some new memory area...but b still points to same area.Had it been pass by refrence b would also be pointing to same new area due to code Ab = new B();

  Was this answer useful?  Yes

shan

  • Feb 8th, 2007
 

hai, in java program we can break the firewall between the registry and the program. So we can access the memory directly, because of that we are not using the pointers in java.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions