1. Vectors in Java
Vectors are extensible arrays, they are empty when first created and can grow and shrink on high end. Vectors are defined in java.util package.
The general specifications of vectors in java are:- • Values from primitive data types like int, char and Boolean cannot be stored in Vectors. • Primitive values can be used in contexts requiring objects by wrapping them in objects (Wrapper Classes). • Each primitive type has an associated object type. Eg: Integer?int, Character char. • Contains elements numbered from zero up to length-1. • Length can be determined by size method.
• Each element in vector has the apparent type of Object ? heterogeneous: diff elements of a vector can be objects of diff types. • When created, vector is empty. Its length = 0.
? Add element in vector:
“abc”
? Vector elements can be accessed for legal indices. Use gets method to access the indexed element.
? Method get returns an Object. Cast the result to the respective type.
? To change element in a vector, use set method. Eg:
? Elements in vectors must be of types that are subtypes of Object. ? Vectors cannot contain elements of primitive data types such as int and char. ? You can use associated object types.
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
|