Solved

linked list

Posted on 2001-06-03
8
205 Views
Last Modified: 2013-12-14
how do i create a  class using which a linked list can be created given an integer array as input through main
0
Comment
Question by:abi_jacob
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6151070
Java already has a LinkedList class.
If you just need a list and you're not fussed about whether it is implemented as a linked list or not you could use the following:

Object[] array = .....;
List l = Arrays.asList(array);

Or if you explicitly require a linked list try:

LinkedList l = new LinkedList(Arrays.asList(array));



0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6152563
sorry to hijack this thread, abi_jacob: could you please follow up on your other question http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20115531 which has had no response from you for nearly a month.
0
 

Accepted Solution

by:
surendraboppana earned 50 total points
ID: 6160201
if ur not really interested in how the linked list works u  can directly use 'LinkedList' class defined in "java.util.LinkedList".u can use the predefined methods like

1.add(object)
2.remove(Object)
3.boolean contains(object)
4.indexOf(object)etc.
5.u can sort the elements using the algo's in 'Collections'
"sort()"

here isthe sample code

public void main(String args[])
{
    Object array[]=..
    LinkedList ll=newLinkedList(aslist(array []));
 
}
  now the linkedlist ll contains all the elements of the array.


i think this should do
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 43

Expert Comment

by:TimCottee
ID: 6160249
surendraboppana please read the guidelines on comments vs answers at the bottom of the page. Your "answer" is substantially similar to a comment already posted. It is considered bad form to post answers in this way and continued posting may lead to your account being referred to customer services for possible penalty.
0
 
LVL 92

Expert Comment

by:objects
ID: 6161972
Thanks Tim, you saved me a few keystrokes.
Answer proposing seems to be on the rise :(
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6162924
objects, no problem I know I hijacked the thread in the first place to prod abi_jacob into a response, (I think that he/she may now have abandoned this one as well) but even I as a non-java person can see that the "answer" is pretty much what you had already said. I can't let that sort of thing go without a response. I wish they would fix that withdraw proposed answer option soon, especially when you have a questioner that seems to have abandoned the thread, there is nothing you can do about it except contact CS.
0
 
LVL 92

Expert Comment

by:objects
ID: 6162946
Personally don't see the point in having a "Propose Answer" option at all. Personally I've never used it.
Only the question asker can tell if there question has been answered.
0
 
LVL 92

Expert Comment

by:objects
ID: 6169714
abi_jacob,

Poor form!!!!
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question