Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

linked list

Posted on 2001-06-03
8
Medium Priority
?
209 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

772 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