Why java dosen\'t support pointers?

Showing Answers 1 - 23 of 23 Answers

Raman

  • Feb 8th, 2006
 

in wat way does pointers affects security ???

if it is given by example it will be of great help

thanks

  Was this answer useful?  Yes

Anbarasi

  • Feb 8th, 2006
 

java doesnt support pointers as its a tedious job to locate memory as in c++.one of the major problem in most oops languages is to handle memeory allocation.programmer had to explicitely handle memory for the programs max utilization.java doesnt support pointers but consist of builtin functions to handle memory.

  Was this answer useful?  Yes

Anbarasi

  • Feb 10th, 2006
 

can u explain how its for security reasons

  Was this answer useful?  Yes

Manish

  • Feb 13th, 2006
 

Hi,

I think its like this. Consider the analogy that your enemy knows where exactly you are staying(ie your residence). Then, it is very easy for him/her to attack you(Atleast he doesnt have to trace you....).

Similarly, in C++ and C , you can programatically allocate a particular memory location to a variable. Hence, if a hacker wants he can wrie a program to fidn the sensitive data....It is not all that simple as it seems though;)

In Java, the JVM handles the allocation of the memory and its garbage-collection. So, you really would not know(or its very very difficult to find..) the exact location of a variable.

I hope I could answer the security part.

Thanks and Regards

Manish

  Was this answer useful?  Yes

Pavan

  • Feb 14th, 2006
 

Hey guyz...

its not becoz therez something like an Indo-Pak thing going on between the programmer and the hacker...

Just envision a scenario in which u declare an array varArray[10] of 10 members in c or c++... so, it should mean that u can have varArray[0] to varArray[9] legally... But since C and C++ support pointers, and a pointer is any memory location, u can just say:

for(i=0; i <100; i++)

{

printf("%d", varArray[i]);

}

which means that u are illegally invading those memory locations outside your purview. The array logic and all other variable logic includes the ValueAtPointer Indirection and all those aspects which makes Pointers the LoopHoles thru which u can peep through... even into the system level stuff... thats why they are disallowed in Java in addition to issues like Memory Leak.

Ok... Have Got Work To Do...

Take Care...

C Ya...

Pavan.

  Was this answer useful?  Yes

anupama

  • Mar 7th, 2006
 

what ever u said for security it is right.but java supports pointers internally not explicitly.

if as u said not support pointers then what abt this statements

simple s1 = new simple();

here s1 what? this reference r not?that y java supports pointers internally..............

  Was this answer useful?  Yes

srinivasa

  • Mar 10th, 2006
 

hi  anupama,

u'r right . java internally makes use of pointers. bcoz java soft ware is designed by using c programming.

okey bayee....

keeps smiling and mailing

bora_srinivasarao@yahoo.co.in

  Was this answer useful?  Yes

japa2001in

  • Mar 14th, 2006
 

Due to 3 reasons from my view,1. Pointers is complex concept and Java wants to b an easily understood language.2. For security reasons. Pointers refer to the memory locations directly which is a threat to a programmer.3. Java provides all data in the form of refrences then there's no need of pointer concept.

  Was this answer useful?  Yes

bapi1979_4u

  • Mar 14th, 2006
 

HI all,

i had seen the view of all but the picture is not clear.

I mean the strong point is still missing anyone can point on it?

J Prasanna

  Was this answer useful?  Yes

malla reddy

  • Mar 14th, 2006
 

as the java softpeople developed the java lang for simple and more efficient. The pointers is a more confusing thing in c so they removed and other reason is for security. it also control virus from this, pointers may crash the program

  Was this answer useful?  Yes

praveen

  • Mar 16th, 2006
 

Pointers are used to allocate dynamic memory in C and C++.When you create a pointer you have to allocate and deallocate memory for it or else the program would cause memory leaks. Java has come up with the concept of Garbage Collection which actually deletes the memory for you automatically and it cleans up all the unused references automatically when the application runs out of memory.The pointer concept is implement internally in java reducing the complexities and all the cleanup is done by implementing the finalize method.

  Was this answer useful?  Yes

Ashish

  • Mar 16th, 2006
 

Pointers actually provide a good fascility to achive the address of any part of memory. This special property can be used to break the security of files and enable us to made any such program which may be termed as virus.

  Was this answer useful?  Yes

Hi,

I too agree with the guyz who said security reasons.Thru pointers,we can access the memory locations directly,as in C,C++ which is harmful for security reasons,Java does not support.

Secondly,it could be because of platform independence.

Regards

Praths.

  Was this answer useful?  Yes

Naresh Kumar

  • Mar 20th, 2006
 

In the same way becase u r not able 2 know the memory location address of any varible and hence the basic strong security feature can be implement in JAVA.

This is the only reason why java is SECURE.

  Was this answer useful?  Yes

Amasidda

  • Mar 23rd, 2006
 

Because it will breach the fire wall between the JVM and applets.

  Was this answer useful?  Yes

Rammohan

  • Mar 27th, 2006
 

Hi,

one thing i have to tell if you need to access the object information you need some reference(ref) . so with out ref we cant access the object.here the java internally supports pointers but not externally.how it is the sense

Test t1=new Test();

Here t1 is the ref of Test().that mens the object address is stored in t1.but we cant find out the address which is stored in t1.but we can do in c or c++

using  printf("%d",&t1);

so java internally supports pointers.but for the security constraints it doesnt provide the facility to print the value of ref(t1).

Thanks

Ram.

  Was this answer useful?  Yes

dpraveense

  • May 11th, 2006
 

Well, it's debatable whether Java does or doesn't support pointers.Some would say that everything (well, every reference type) in Java isa pointer -- hence, the ever-familiar NullPointerException. Butcertainly, these reference types do not give one the sort of directinteraction with memory that we're familiar with from pointers in,e.g., C. The decision to have it this way has to do with the designprinciples of Java. Security and portability are probably two of themain ones. In Java, can you access uninitialized or deallocatedmemory? Well, that's because of the lack of pointers. Like it or lumpit, that's Java.

  Was this answer useful?  Yes

Joseph Kiernan

  • Jul 27th, 2006
 

All wrong, including the question. Java *does* support pointers. See the JLS. It's just that they don't have all the semantics of C/C++ pointers, specifically pointer arithmetic or the ability to point to abritrary addresses.A Java reference is defined as a pointer whose value is not null, and which therefore refers to an object.

  Was this answer useful?  Yes

Joseph Kiernan

  • Jul 27th, 2006
 

It does support pointers and the question is therefore invalid. See the Java Language Specification. Java just doesn't support them with the wild abandon of C/C++ where any integer is a pointer. A reference is defined in the JLS as a pointer whose value is not null.I've alreayd posted this today. If the moderators of this place don't agree with this statement I encourage them to check for themselves. Considering the number of wrong answers that are already on this site I don't know what the problem with the occasional right answer can be, if only just for a laugh.

  Was this answer useful?  Yes

Hi anupama

Actually, java does not use pointers.

s1 is an object.

Let us consider the following situation.

If you write username and password in your login page using pointer. go and see the view source or see url. it will show your username and password.

Pointer means that to store reference of an object in to a particular address.

when you get username and password using objects, ie., s1.username, s2.password that will not find by hackers

If am wrong/right reply me

Txs

Premmm

  Was this answer useful?  Yes

Premm, see replies #20 and #21, and the JLS.If Java doesn't have pointers why are they mentioned in the JLS? and why does it have a NullPointerException?It doesn't have pointers with the semantics you describe: that's a different issue.IMHO what it doesn't have is *references* actually.

  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