What I don't understand is that, it is being said that java doesn't support pointers as c++ for more security, so why is "this pointers" are used??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What I don't understand is that, it is being said that java doesn't support pointers as c++ for more security, so why is "this pointers" are used???

28th Jul 2016, 4:37 PM
kartik shouche
kartik shouche - avatar
4 Answers
+ 1
I think you misunderstood the use of this as an object reference in java, when we create object variables we refer to them as references or pointers because they point to the object. this is used the same way to refer to the current object you are working on. The pointers on a c++ context are not similar to "this" in java
28th Jul 2016, 6:38 PM
Nick Nderitu
Nick Nderitu - avatar
0
Pointers allow you to modify variables by using their unique addresses. kind of like being able to change a TV channel using a remote rather than going to the actually Telly. A programming language with support for pointers has a lot more power compared to one that doesn't. This power can be used for malicious purposes. That's the simplest way I could answer you
28th Jul 2016, 5:28 PM
Nick Nderitu
Nick Nderitu - avatar
0
I know what pointer is , java doesn't support pointers as it is said. but it still does support "this pointers" why??
28th Jul 2016, 5:32 PM
kartik shouche
kartik shouche - avatar
0
in java's context the this is not a pointer but a reference to the class where it is used
21st Oct 2016, 9:08 PM
PANKAJ KUMAR
PANKAJ KUMAR - avatar