File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pointers in Java

 
Parth Bhatt
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
Was asked this quesion by my lecturer(& was left speechless ) Heres' the question...

SUGGEST A WAY BY WHICH POINTERS CAN BE IMPLEMENTED IN Java...!!

The question expects a suggestion that has a mechenism that shows pointers being implemented logically in java code... I have heard that it can be done using interfaces, not sure if its true though...!!

Can anyone sugest the solution...??
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pointers to what?
 
Tony Morris
Ranch Hand
Posts: 1608
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your teacher is asking you to read his/her mind to determine his/her definition of "pointer", which almost certainly does not align with any of the 'de facto' definitions, since I can't think of any reasonable one, even one that I don't entirely agree with, that would allow your question to be correctly answered.

Good luck, I recommend the Stealth Max V2 Crystal Ball "rub and be enlightened". I use it at work quite successfully.
 
Parth Bhatt
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, agreed....!! am guilty of not being specific...!!

was expecting to know the use of pointers for implementing data-structures(Linked Lists, IN PARTICULAR)...

Suggect a way to implement a Linked List in Java...!!

Thanks
[ December 11, 2005: Message edited by: Parth Bhatt ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Besides

new java.util.LinkedList() ?

All variables that refer to objects in Java are pointers. We generally like to say "references" instead, but they're pointers just the same. The only difference between Java pointers and C pointers is that you can't do "pointer arithmetic" in Java -- you can't subtract pointers, or convert to and from integers. But a Java variable points to an object in just the same way that a C pointer does; it can be reassigned to point to another object, or set to null (no object).

So if you know what a linked list is, and how to implement one in C/C++, then just do it the same way in Java.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic