We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › arraylist synchronization syntax
Page Index Toggle Pages: 1
arraylist synchronization syntax (Read 775 times)
arraylist synchronization syntax
Aug 8th, 2008, 12:29am
 
    Hello P5! Glad to post new topic but sad that it happens because of problem.
 I've written  ArrayList wich adds 1 graphical object from this object's class when the button is pressed. The objects are picked and moved by mouse , the methods are inside the class. ArrayList's (of obhects) functions added with help of "for int i" function.
 Here is the problem(s):
 When I create new object the olds get default data of new one and than do evrth. together.
 I decided to synchronize the ArrayList...  Smiley
 What did I get for  today:
1) List list = synchronizedList(new ArrayList(9));
  Tells : the type List is ambiguous.
2) Vetor myVector... myVector.add(new Object());
  Tells : vector is not applicable
3) Vector myVector... myVector.addElement(new Object());
  Tells : the function doesn't exist.

Wich way P5 accepts the code above?
Wich way is the best to synchronize my objects?
Re:  arraylist synchronization syntax
Reply #1 - Aug 8th, 2008, 10:06pm
 
  There is good explanation for my question:
http://forums.sun.com/thread.jspa?forumID=31&threadID=750373
  But what is wrong with List and Vector?
Re:  arraylist synchronization syntax
Reply #2 - Aug 9th, 2008, 5:17pm
 
The "List" type is found in java.awt and java.util, so you have to specify which one, since both are imported by Processing.

The other code should work fine, but it looks like you have some typos.

Also note that if you're using release 0135, you can only use Java 1.4 syntax (and methods):
http://processing.org/faq.html#java

If you're using 0136 or later, you can use Java 1.5 methods and classes, but not Java 1.5 syntax.
Re:  arraylist synchronization syntax
Reply #3 - Aug 10th, 2008, 6:44pm
 
  Thank you fry. It really was hard to find it out for me - beginner in programming world (4 month). But Processing good learning, good discourse and good people made myself studying very easy. I appreciate this very much.
  Thank you again fry and all P5 people.
Re:  arraylist synchronization syntax
Reply #4 - Sep 13th, 2008, 12:08am
 
fry wrote on Aug 9th, 2008, 5:17pm:
The "List" type is found in java.awt and java.util, so you have to specify which one, since both are imported by Processing.


I am running into the same issue (type List is ambigious error). How do you specify which one to use exactly. I'm not really sure how to do this.

Thanks in advance
Re:  arraylist synchronization syntax
Reply #5 - Sep 13th, 2008, 1:05am
 
Just put the name of the package in which it belongs before the class name. In other words java.util.List instead of just List.
Re:  arraylist synchronization syntax
Reply #6 - Sep 13th, 2008, 1:23am
 
thanks a lot for the quick reply.

/Camille
Page Index Toggle Pages: 1