Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

linked list

Posted on 2001-06-03
8
Medium Priority
?
208 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 150 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

715 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