Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Pointers in Java Posted by VinayKhare on 3 Aug 2010 at 11:09 PM
hello,

I need to create a chain of objects, with links in common.
In C++, I made a class like.
//Linked List of 10 nodes.
class link{
 link *left;
 int data;
 link * right;
 public:
 CreateLink(link *a,link *b){
  left = a;
  right = b;
 }
};

int main(){
 link obj[10];
 obj[0].CreateLink(NULL,&obj[1]);
 for(i=1;i<9;i++){
  obj[i].CreateLink(obj[i-1],obj[i+1]); 
 }
 obj[9].CreateLink(&obj[8],NULL);
}


How would I achieve the same task in Java without using LinkedList or List type or classes??

I want to make a variable(int,char etc) that is common to two adjacent objects and not to all the objects of that class!

Please help.

Regards,
Vinay




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.