Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Linkedlist and live data
 Post subject: Linkedlist and live data Post rating: 0   New post Posted: Fri 17 Jul, 2015, 11:57 
User avatar

User rating: 0
Joined: Fri 17 Jan, 2014, 17:43
Posts: 16
Hello, I want help please.
How can I put live data in LinkedList for create a list few elements?

I try this code that put the new data in [0] index but no keep old data in the list as I would like.
List l = new LinkedList();
l.add(open);
for (int i = 0; i< l.size(); i++)
System.out.println(" Element à l'index " + i + "=" + l.get(i));
The code put the new data but remove the oldest.
My target is create a dynamic list of two elements, a new data and the previous.

Have a nice day!
Best regards


 
 Post subject: Re: Linkedlist and live data Post rating: 0   New post Posted: Fri 17 Jul, 2015, 13:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
list.add(Object o); // Appends the specified element to the end of this list 
list.remove(int index) // Removes the element at the specified position in this list (optional operation).

Hence in this case we need the following
list.add(open);
list.remove(0);


 
 Post subject: Re: Linkedlist and live data Post rating: 0   New post Posted: Fri 17 Jul, 2015, 15:26 
User avatar

User rating: 0
Joined: Fri 17 Jan, 2014, 17:43
Posts: 16
Thank you for your help, I try this immediately.
Have a good weekend!!


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com