Solved

linked list

Posted on 2001-06-03
8
204 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven disable workspace resolution 1 43
Export all vba modules from outlook vbaproject.otm 7 50
Setup GlassFish 4 37
Netbeans and org.apache.commons.lang3 issue 3 29
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

730 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