|
The list is synchronized across all threads as described here[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Is this a part of method declaration or what ?
|
|
|
|
|
No it's the constructor as described in the link I gave you. As it says in the description "Returns a synchronized (thread-safe) list".
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hello
Please check out the following picture:
http://i55.tinypic.com/35mk6eq.png[^]
I am interested in knowing what the left and right arrows mean precisely.
Does the arrow to the right mean that 'Thread' is dependent on 'Runnable'?
What does the left (bottom) arrow mean?
Someone told me it means 'inherits'.
I'm not sure how that relates to 'implements'.
It's all a bit fuzzy to me still.
Thank you for reading.
Regards,
|
|
|
|
|
MyRunnable implements the Runnable interface. Runnable extends Thread.
See David Skelly's answer....
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
Wrong way round. Thread implements Runnable.
|
|
|
|
|
bugger.....Reading your answer, i might be half right!
I'm sure i've seen the exact same diagram in my uni course texts, but i can't find it. It will be buried somewhere.
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
This diagram isn't really UML so it is hard to know what it is intended to show.
In UML, the solid arrow means that Thread implements Runnable (Thread is a Runnable).
The other arrow is an open arrow and in UML this would normally represent a "has a" relationship rather than "is a". So, this would mean that MyRunnable has a Runnable, and the concrete implementation of that Runnable is a Thread.
However, the names of the classes in this example lead me to think this is not what is intended.
It might be that MyRunnable implements Runnable, and this runs as the target of a Thread, in which case the meaning of the symbols would be completely reversed. MyRunnable is a Runnable, and Thread has a Runnable target.
In other words, this diagram could have two completely opposite meanings. It is not a good diagram.
|
|
|
|
|
Hello,
I define a class as bellow
public class Items
{
public int id;
public String model;
public String type;
public String name;
public String description;
public String creator;
public Date created;
public void setId(int _id)
{
this.id = _id;
}
public int getId()
{
return id;
}
public void setModel(String _model)
{
this.model = _model;
}
public String getModel()
{
return model;
}
public void setType(String _type)
{
this.type = _type;
}
public String getType()
{
return type;
}
public void setName(String _name)
{
this.name = _name;
}
public String getName()
{
return name;
}
public void setDescription(String _description)
{
this.description = _description;
}
public String getDescription()
{
return description;
}
public void setCreataor(String _creator)
{
this.creator = _creator;
}
public String getCreator()
{
return creator;
}
public void setCreated(Date _created)
{
this.created = _created;
}
public Date getCreated()
{
return created;
}
public Items(int Id, String Model, String Type, String Name, String Description, String Creator, Date Created)
{
this.id = Id;
this.model = Model;
this.type = Type;
this.name= Name;
this.description = Description;
this.creator = Creator;
this.created = Created;
}
}
next, I have another class and in this class I define a method with argument
public class dataInteraction
{
public static insert(int id, String model, String type, String name,
String description, String craetor, Date created )
{
ArrayList arrayList = new ArrayList();
arrayList.add(??????????????)
}
}
my question is do I have to add argument or class?
arrayList.add(Items)
or
arrayList.add(id);
.
.
.
arrayList.add(created);
|
|
|
|
|
1) You probably don't want to create your list in the insert method: if you do so, you will create a new list each time the insert method is called (and I guess it's not what you want). So, preferably make it a member of your DataInteraction class (and create it in the constructor of the class).
2) It's a bit strange that you call the class Items and not Item . Is this class supposed to represent multiple items or only one ? From your code, I guess it should be called Item .
3) I guess you want to store several items in your array list. If so, simply create an instance of the Item class when you call the insert method and add the object to the list:
public class dataInteraction{
public static insert(int id, String model, String type, String name, String description, String craetor, Date created ) {
Item newItem = new Item(id, model, type, name, description, creator, created);
arrayList.add(newItem);
}
}
|
|
|
|
|
thanks for your reply,
this class shows multiple items.so, do I need to call item or items?
as I am beginner, regarding to your advice(1), do you reckon if my array be a member of DataInteraction class is better or do I have to put inside the insert method. the reason I put inside the method is, I wanna call this method in another class to assign data.
I would be happy if you tell me any suggestion.
thx
|
|
|
|
|
I think you are missing some fundamental concepts on object oriented programming. It would help if you read your class book or some tutorial about classes first.
future3839 wrote: this class shows multiple items.so, do I need to call item or items?
Which class will contain multiple items ? The dataInteraction class or the Item class ? Furthermore, dataInteraction is I guess not a really useful name. What do you want to do with the list of objects ? You probably don't need the dataInteraction class anyway but use the list directly.
future3839 wrote: the reason I put inside the method is, I wanna call this method in another class to assign data.
If you create the list inside the method, each time the method is called, a new list is created. Furthermore, the method has to return the list (you forgot the return type of the method) otherwise it will be "lost" (you don't have any reference to it anymore so you can't manipulate it).
|
|
|
|
|
You may be better using one of the built in collections classes; see the tutorials[^] pages for some good examples.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
ArrayList is one of the built in collections classes
|
|
|
|
|
It was the very first one, unless you consider Array a collection as well (it doesn't grow well).
|
|
|
|
|
It may be the first alphabetically but it was not the first in the language. It wasn't added to Java until release 1.2. Prior to that we just had Victor the Vector.
|
|
|
|
|
I stand corrected. While I have been using Java quite a lot, almost from its start, I don't remember not having ArrayList...
|
|
|
|
|
The java.util collections classes were Joshua Blosch's work, before he left Sun and made lots of money writing books.
Sadly, I have been using Java since the 1.1 days (longer than I care to remember), and I remember the new collection classes being added, and Vector being retro-fitted with the "new" List interface. That's why we have Hashtable and HashMap as well. Hashtable has been there since 1.0, HashMap is one of the 1.2 generation of collection classes.
|
|
|
|
|
I really must learn to read properly.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Oh don't do that Richard! Have another GnT, take a deep breath and carry on as before.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
Nagy Vilmos wrote: Have another GnT
Don't mind if I do; Cheers!
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi,I want to implement Table control with GEF.Does anybody have examples like that?
Any suggestion will be appreciate.
modified on Monday, September 27, 2010 8:02 AM
|
|
|
|
|
hello i have almost completed my project in java and i want to know is there any way possible to refresh table component or other values residing on mainFrame form of application on closing a separate frame/window/dialog (not child)
--------------------------------------
The same i want with jpanels showing within tabs but thats an issue of less priority
Alok sharma
|
|
|
|
|
|
Hello,
when I create new project in Java desktop application. a for Automatically create. now, I add another jframeform. my question is how to make the new form as default. i wanna after running project my form show up.
|
|
|
|