Return Type in Java

Asked 2 years ago, Updated 2 years ago, 29 views

The return type of the function findViewById(); is a View Class, but why should the person receiving this return value be a View or a Data Type that inherits View such as textView? Aren't you going to get the address money anyway? Can't Int or float just get the address? Where is the address value and the type of data in that address matched and stored?? Does the type mean more than the size of the data?

I feel like it's a ridiculous question, but I'd appreciate it if you could give me a rough idea!

java android

2022-09-22 21:11

1 Answers

Java does not allow direct handling of memory addresses. In other words, it is understood that it does not provide an interface that deals directly with addresses like C/C++. Therefore, it is impossible to manipulate the object by receiving the address value with the int and float you mentioned.

In Java, when you assign an object to a variable, you have a reference to that object. You may understand that the way this reference finds objects, from a C/C++ perspective, behaves similar to a pointer, but that does not mean that it can handle the address value of memory.


2022-09-22 21:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.