We help IT Professionals succeed at work.

need help with basics of java programming

d_terano
d_terano asked
on
hello,

     i'm very new with java programming. can anyone give me example codes for the below function
in the programming languages mentioned above? :

1.add a record
2.delete a record
3.search a record
4.update a record
5.print that record

extra examples on arrays and data structures (linked list) are welcome

thank you for yor help and patients...

d_terano.
Comment
Watch Question

Commented:
It depends to what you want to add,delete,... a record. It can be a Vector, HashSet, ... (see package java.util.*)

But lets say you want to make the operation on a Vector:

Vector myVector = new Vector();
MyObject myObject = ... can be any java object

myVector.add(myObject);  // add an record to the vector

myVector.remove(myObject);  // removes the myObject
myVector.remove(4);  // removes the object that is on position 4 in the vector (pos 0 is the first entry)

myVector.contains(anOtherObject)  // search

myVector.add(index, myObject); // update a Vector can hold more then one time the same object so you have to specify the position of the old object that you want to replace (update)

loop over the vector and print the entrys out
Enumeration enum = myVector.elements()
while(enum.hasMoreElements())
{
  System.out.println(enum.nextElement().toString());
}


I hope that will help you otherwise see java dokumentation it is not a bad one ;-)



Author

Commented:
thanks for your patients, time and help...

Explore More ContentExplore courses, solutions, and other research materials related to this topic.