• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Pointers in Java

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...??
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pointers to what?
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author and iconoclast
Posts: 24208
47
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic