Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Make a linked list without pointers?

linked list pointers
0
Posted

Make a linked list without pointers?

0

Short answer: Use the Vector class in java.util. It can do anything a linked list can do and a little more and saves you a lot of coding which, after all, is the point of OOP and the class library. However it is array based so insertions or deletions from the middle of a Vector are not as efficient as with a true linked list. Long answer: Object variables in Java are all references. A reference acts like a pointer in most other languages. (Though they’re handles, not pointers, in most Java implementations. The notable exception is Microsoft’s.) The main difference is that you can’t do pointer arithmetic on references. Therefore wherever you’d use a pointer to an object in C++, in Java you should just use the object itself. On the other hand the primitive data types (int, float, double, char, byte, short, long and boolean) are not references. If you want to get a reference to one of these you need to wrap it in a class first. Java provides ready-made type-wrapper classes in the java.lan

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123