Results 1 to 5 of 5
Thread: Help Vector
- 12-09-2010, 10:41 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
Help Vector
Hello i am new to java
I want to develop a software application for salary management.
How to add and to substract Ergazomenos (Employee in Greek) in the total Ergazomenos in which he is Proistamenos( Boss in Greek)?
Proistamenos extends Ergazomenos
In main i wrote this:
public static void main(String[] args) {
Ergazomenos e1=new Ergazomenos("n","v",2000f, 200f, new Date(12,3, 1989),new Date(12,3, 1989), 40,new Date(12,3, 1989),14);
Vector erg=new Vector();
if(erg.contains(e1))
erg.add(e);
else
System.out.print("Do nonthing");
if(erg.contains(e1))
erg.remove(e);
}
- 12-10-2010, 03:39 AM #2
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 10
Quick Vector tutorial for holding objects
Java Vector,Using Vectors in Java,Vector Object in Java,Online Java Vector ExampleLast edited by al_Marshy_1981; 12-10-2010 at 03:40 AM. Reason: cannot spell Vector anymore
- 12-10-2010, 01:23 PM #3
You mentiond that you are just newbie. So better use ArrayList instead of Enumeration
Mak
(Living @ Virtual World)
- 12-11-2010, 04:57 PM #4
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
I have a question. The object erg is from the class Ergazomenos and the object proist is from the class Proistamenos. Do i have to write
ArrayList erg=new ArrayList();
ArrayList proist=new ArrayList(); or
ArrayList<Ergazomenos> erg=new ArrayList<Ergazomenos>();
ArrayList<Proistamenos> proist=new ArrayList<Proistamenos>();
I want to copy Ergazomenos objects to Proistamenos in order to substract or to add Ergazomenos from Proistamenos
in main i wrote this......
Ergazomenos e1=new Ergazomenos("n","v",2000f, 200f,new Date(12,3, 1989),new Date(12,3, 1989), 40,new Date(12,3, 1989),14);
Ergazomenos e2=new Ergazomenos("ng","gv",2000f, 200f,new Date(12,3, 1989),new Date(12,3, 1989), 40,new Date(12,3, 1989),14);
ArrayList erg=new ArrayList();
ArrayList proist=new ArrayList();
erg.add(e1);
Proistamenos p1=new Proistamenos ( "n", "h",
44, 12, new Date(12,12,1212),
new Date(12,3, 1989), 14, new Date(12,3, 1989), 12,
"ionio", new Date(12,3, 1989),
new Date(12,3, 1989), 30, 10);
proist.add(p1);
// Proistamenos(String onoma, String epitheto, float
// vasikosMisthos, float Iperoria, Date imerominiaProslipsis,
// Date imerominiaGennisis, int afm, Date imerominiaApolisis, float antimisthia,
// String onomaTmimatos, Date ImerominaProistamenos, Date
// ImerominiaPausisProistamenos, int numberOfErgazomenous, int epidomaThesis) {
//
System.out.println("Before copy second Vectors contains\n "+proist);
proist.addAll( erg);
// Collections.copy(proist, erg);
// proist.addAll(erg);
System.out.println("After copy second Vectors contains\n "+proist);
//System.out.printf("vector contains \n\n %d\n ",erg.indexOf(e1));
//System.out.println("e1 " + e1.toString());
if(erg.contains(e1))
System.out.println("true");
erg.remove(e1);
if(erg.contains(e1))
System.out.println("true");
- 12-16-2010, 06:27 AM #5
ArrayList erg=new ArrayList();
ArrayList proist=new ArrayList();
it means that you can add any object into list erg, proist.
ArrayList<Ergazomenos> erg=new ArrayList<Ergazomenos>();
ArrayList<Proistamenos> proist=new ArrayList<Proistamenos>();
It means that you can add only Ergazomenos objects in list erg and you can add only Proistamenos objects in list proist.
Hope this helps you.Mak
(Living @ Virtual World)
Similar Threads
-
Vector<vector> loop thru
By ocean in forum New To JavaReplies: 11Last Post: 11-21-2009, 03:17 PM -
Vector
By sanox in forum New To JavaReplies: 20Last Post: 09-01-2009, 05:21 PM -
Vector
By MuslimCoder in forum Advanced JavaReplies: 4Last Post: 08-06-2009, 04:44 PM -
Vector<Point2D> list = new Vector<Point2D>();Is it possible for 15,000 Point2D obj???
By Mazharul in forum Java 2DReplies: 1Last Post: 04-06-2009, 07:45 AM -
Vector help
By king_arthur in forum New To JavaReplies: 3Last Post: 01-22-2008, 08:33 PM
Bookmarks