Solved

linked list

Posted on 2001-06-03
8
201 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
  • 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now