0

Hi Guys, i'm new to java and i need a code like a student form or employee on how to add, search, and delete a data in an array or list.. i'm very confused and i really need your help.. thanks.

3
Contributors
2
Replies
5
Views
7 Years
Discussion Span
Last Post by kvass
0

I recommened you to try with your self and then If you have a compilation error or any problem post it here

1

Arrays
To create an array use the following general syntax: dataType[] arrayName = new dataType[arraySize]; Accessing Size: arr.length Accessing Data: arr[index] Modifying Data: arr[index] = var Insertion: Not Applicable
Deletion: Not Applicable


ArrayLists
To create an ArrayList use the following general syntax: ArrayList<DataType> arrayName = new ArrayList<DataType>(); Accessing Size: arr.size() Accessing Data: arr.get(index) Modifying Data: arr.set(index,val) Insertion: arr.add(index,val) or arr.add(val) if you want to add it to the end.
Deletion: arr.remove(index)

Notes on ArrayLists:
1. You must import java.util.ArrayList before using them.
2. If you remove a value from an ArrayList, the values later in the list will move up to fill the gap. If you insert a value into an ArrayList, the value there and the values after it will move down to make room.

Edited by kvass: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.