|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

05-01-2008, 05:29 PM
|
|
Member
|
|
Join Date: May 2008
Posts: 6
|
|
|
i need same of help
Hi every body
How are you??
i need same of help plz
Could anyone solve for me this problem??
thank you for your help
Due: May 4, 2008
1. Create your own version of the Java program to implement a linked list as explained in class.
2. Create a Java program for doubly linked lists and provide input and output.
3. Analyze examples with generic classes given in class used in building linked lists. Make your own example.
|
|

05-01-2008, 05:31 PM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 19
|
|
Well, it's hard to do any of that without being in your class? 
|
|

05-01-2008, 05:43 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 250
|
|
Ofcourse...
Due: May 4, 2008
1. Create your own version of the Java program to implement a linked list as explained in class.
2. Create a Java program for doubly linked lists and provide input and output.
3. Analyze examples with generic classes given in class used in building linked lists. Make your own example.
Try to attempt an effort..... There are experts here that are ready to help you out....(problem about your code.)
__________________
best regards, 
sukatoa
Last edited by sukatoa : 05-01-2008 at 05:45 PM.
|
|

05-01-2008, 06:34 PM
|
|
Member
|
|
Join Date: May 2008
Posts: 6
|
|
|
its an assignment if you need to attemt the lecture i will
|
|

05-01-2008, 06:35 PM
|
|
Member
|
|
Join Date: May 2008
Posts: 6
|
|
|
|
|

05-01-2008, 06:58 PM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 19
|
|
|
Like Sukatoa, said try this yourself, first. I will gladly help you, but give this a honest attempt. Understanding Linked-list is really important if you plan on continuing programming.
|
|

05-09-2008, 10:44 AM
|
|
Member
|
|
Join Date: May 2008
Posts: 6
|
|
|
this is my code what the wrong with it
public class DoublyLinkedList
{
public static void main(String args[])
{
DoublyLinkedList<Integer> list = new DoublyLinkedListinkedList<Integer>();
list.addHead(new Integer(1));
list.addHead(new Integer(2));
list.addTail(new Integer(9));
list.addHead(new Integer(3));
list.addTail(new Integer(11));
list.add(2, new Integer(0));
System.out.println(list);
list.remove(list.size());
System.out.println(list);
}
}
|
|

05-09-2008, 11:14 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
Lots of errors I can found there pal. Here what you have to do.
import java.util.LinkedList;
public class DoublyLinkedList {
public static void main(String[] args) {
LinkedList <Integer> list = new LinkedList<Integer>();
list.add(new Integer(1));
list.add(new Integer(2));
list.add(new Integer(9));
list.add(new Integer(3));
list.add(new Integer(11));
list.add(2, new Integer(0));
System.out.println(list);
list.remove(0);
System.out.println(list);
}
}
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-09-2008, 11:18 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
|
Still you have lots of things to learn there.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-09-2008, 11:44 AM
|
|
Member
|
|
Join Date: May 2008
Posts: 6
|
|
|
thank you very much for your help
|
|

05-10-2008, 11:16 AM
|
|
Member
|
|
Join Date: May 2008
Posts: 1
|
|
Originally Posted by Eranga
Lots of errors I can found there pal. Here what you have to do.
import java.util.LinkedList;
public class DoublyLinkedList {
public static void main(String[] args) {
LinkedList <Integer> list = new LinkedList<Integer>();
list.add(new Integer(1));
list.add(new Integer(2));
list.add(new Integer(9));
list.add(new Integer(3));
list.add(new Integer(11));
list.add(2, new Integer(0));
System.out.println(list);
list.remove(0);
System.out.println(list);
}
}
how does this programme work
can you tell me each code how work plz
|
|

05-10-2008, 12:02 PM
|
|
Member
|
|
Join Date: May 2008
Posts: 6
|
|
|
hi
i have this programme i don’t know why does not work with me
class Queue<T> {
private LinkedList<T> items = new LinkedList<T>();
public void enqueue(T item) {
items.addLast(item);
}
public T dequeue() {
return items.removeFirst();
}
public boolean isEmpty() {
return (items.size() == 0);
}
public void addAll(Collection<? extends T> collection) {
// Add all the items from the collection to the end of the queue
for ( T item : collection )
enqueue(item);
}
}
Last edited by ayoood : Today at 11:03 AM.
|
|

Today, 04:44 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
Originally Posted by tito84
how does this programme work
can you tell me each code how work plz
First LinkedList is declared and initialized.
LinkedList <Integer> list = new LinkedList<Integer>();
Here you have to define the generic to avoid compiler warnings. Generic is depend on the LinkedList element type. Here it is an Integer. Then populate the linked list. You can do it in different ways.
Just add elements there.
list.add(new Integer(1));
Here actually no need to instantiate a int value. Simply add.
Or you can define the index that where you want to add the element.
list.add(2, new Integer(0));
But you can't skip index there. Then remove element,
Remove the 0th element of the list.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
Last edited by Eranga : Today at 04:48 AM.
|
|

Today, 04:47 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
Originally Posted by ayoood
could you change the name of programme to generic plz
I don't know what you are trying to do. See that your class declaration also incorrect. And defining generics for LinkedList too.
It's much better to do some work with basis of Java, then try some applications like this.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|