Class Vector
java.lang.Object
tema1.Vector
-
Constructor Summary
ConstructorsConstructorDescriptionVector
(int... aelem) Constructor for Vector accepting an array of elements example: Vector myVector = new Vector(1,2,3,4,5,6); example2: Vector myVector = new Vector(1,2,3,4); -
Method Summary
Modifier and TypeMethodDescriptionvoid
Computes the sum of 2 vectors merging the second one in the first one example: Vector myVector = new Vector(1,2,3,4,5,6); Vector myVector2 = new Vector(10,12,13); myVector.add(myVector2) result: myVector now holds: 11,14,16,4,5,6 If the second vector has more elements then the first one, missing elements are merged EXCEPT IT DOESNT JUST DONT ADD A SMALLER VECTOR TO A BIGGER ONE OR UR CODE GONNA EXPLODE Ok it doesnt explode anymore, just ignores whatever is afterwardsvoid
display()
Prints all elements to consoleint[]
getAll()
Returns all elements as an arrayvoid
multiply
(int x) Multiplies all elements in Vector with x example: myVector.multiply(5)int[]
unique()
Returns an array of unique values in the vector
-
Constructor Details
-
Vector
public Vector(int... aelem) Constructor for Vector accepting an array of elements example: Vector myVector = new Vector(1,2,3,4,5,6); example2: Vector myVector = new Vector(1,2,3,4);- Parameters:
aelem
-
-
-
Method Details
-
display
public void display()Prints all elements to console -
getAll
public int[] getAll()Returns all elements as an array -
multiply
public void multiply(int x) Multiplies all elements in Vector with x example: myVector.multiply(5)- Parameters:
x
-
-
add
Computes the sum of 2 vectors merging the second one in the first one example: Vector myVector = new Vector(1,2,3,4,5,6); Vector myVector2 = new Vector(10,12,13); myVector.add(myVector2) result: myVector now holds: 11,14,16,4,5,6 If the second vector has more elements then the first one, missing elements are merged EXCEPT IT DOESNT JUST DONT ADD A SMALLER VECTOR TO A BIGGER ONE OR UR CODE GONNA EXPLODE Ok it doesnt explode anymore, just ignores whatever is afterwards- Parameters:
x
-
-
unique
public int[] unique()Returns an array of unique values in the vector
-