File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Pointers in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Pointers in Java" Watch "Pointers in Java" New topic

Pointers in Java

Parth Bhatt
Ranch Hand

Joined: Oct 19, 2005
Posts: 58
Hi Guys,
Was asked this quesion by my lecturer(& was left speechless ) Heres' the question...


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...??

If your new Big Idea doesn't scare the hell out of you, <br />it's probably not a "new Big Idea".
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Pointers to what?

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
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.

Tony Morris
Java Q&A (FAQ, Trivia)
Parth Bhatt
Ranch Hand

Joined: Oct 19, 2005
Posts: 58
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...!!

[ December 11, 2005: Message edited by: Parth Bhatt ]
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199


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.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Pointers in Java
It's not a secret anymore!