File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is array of pointers & pointers in array?

 
Raams Raj
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,
what is array of pointers & pointers in array??
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raams Raj wrote:Hi to all,
what is array of pointers & pointers in array??


Can you give us some context for this question? Technically, Java references (although they point to objects), are not really pointers ... meaning Java doesn't really support pointers.

Henry
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raams Raj wrote:...what is array of pointers & pointers in array?? ...

A Java array of non-primitives holds references to objects, rather than holding the objects themselves. My guess is that's what this is saying.

But as Henry said, Java does not directly use pointers, and we need more context.
 
Max Rahder
Ranch Hand
Posts: 177
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raams: As you probably gathered from the other responses, the term "pointer" is a bit ambiguous. Both a "reference" and a "pointer" point to something, but reference values are basically hidden from you, whereas pointers can be manipulated. For example, you might do arithmetic on a pointer to change its value, and therefore, point to a different location. In languages with references you can't really get at, and can't manipulate the value. Java uses references, so from your perspective as the programmer, there's no way of knowing the physical location of that object on the heap. To get back to your question, an array of "pointers" probably means an array of some reference type.

Variable "strings" is a reference variable that points to a 2 element array. Each element in the array is also a reference -- the first one references the string "hi" (located at some unknowable location on the heap) and the second one references the string "there" (located at some other unknowable location on the heap).
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raams Raj wrote:Hi to all,
what is array of pointers & pointers in array??


Hi Raams,

Welcome to JavaRanch. Looks like you are from a C/C++ background. Is nt it? For sure you might get this question. Glad that you got it.

I guess other ranchers have given good answers. Does that help?

Simply speaking,

1. Java does NOT have a direct concept/terminology called Pointers. Indeed they are known as 'References'. Semantically the two words mean the same thing, pointing to an object/entity at run time.

2. Having agreed upon the aforesaid note, you can have an array of pointers [array of references] and pointers in array [references in array]. But they both drill down to the same thing finally.

Say for example:



where s1, s2 -> References to a String object.



strArray -> Reference to an object (which is nothing but an array here), holding some other references (s1,s2).
-- Array of References (Array of Pointers)

It can also be said that there are some References in Array (Pointers in Array).

NOTE: In Java you don't have a terminology of acccessing/modifying the content or value of an object being pointed by the pointer through indirection operator (*) and increment/decrement stuff. Because, Java does NOT support pointers.

Does that help?

Please post back if you need further clarifications.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic