Category 1
Array merging, but the array cannot cross-border. To save memory, create an array to merge the array, and then assign a value to the array to be merged.
Package org. se;
// Merge linear tables
Public class arithMetic11 {
Public static int [] la = {, 4}; // use an array instead of a linear table
Public static int [] lb = {, 9 };
Public static int la_len; // get the array Length
Public static int lb_len;
Public arithMetic11 (){
Init ();
// TODO Auto-generated constructor stub
}
Public void Init () // initialize data
{
La_len = la. length; // obtain the array length
Lb_len = lb. length;
}
Public void ListInsert () // insert data
{
Int a; // used to store elements in lb
For (int I = 0; I <lb. length; I ++)
{
A = lb [I];
If (! (LocateElem (a) // determines whether la has an element equal to.
{
Int [] text = new int [++ la_len]; // defines a new array
// System. out. println (la_len); // text = la; if so, the text length is the same as the la length.
For (int j = 0; j <la_len-1; j ++)
{
// System. out. println (la_len );
Text [j] = la [j]; // copy la to text
}
Text [la_len-1] = a; // place a at the end of the new array
For (int x = 0; x <la_len; x ++)
{
GetElem (text );
// System. out. println (la_len );
System. out. println ("la [" + x + "]..." + la [x]);
}
}
}
}
Static boolean LocateElem (int e) // determines whether la has an element equal to.
{
Boolean B = true; // determines whether la has an element equal to.
For (int j = 0; j <la. length; j ++)
{
If (e! = La [j])
{
B = false;
}
Else
{
B = true;
}
}
Return B;
}
Public void GetElem (int [] p) // assign the new array to la
{
La = null;
La = p;
}
}
Category 2
Package org. se;
Public class test {
Static arithMetic11 am;
Public static void main (String [] args ){
Am = new arithMetic11 ();
Am. ListInsert ();
// TODO Auto-generated method stu
}
}