TAILIEUCHUNG - What Is an Array?

một Array là gì? Mảng là một dãy có thứ tự của các nguyên tố. Tất cả các yếu tố trong một mảng có cùng loại (không giống như các trường trong một cấu trúc hoặc lớp, mà có thể có các loại khác nhau). | What Is an Array An array is an unordered sequence of elements. All the elements in an array have the same type unlike the fields in a struct or class which can have different types . The elements of an array live in a contiguous block of memory and are accessed by using an integer index unlike fields in a struct or class which are accessed by name . Declaring Array Variables You declare an array variable by specifying the name of the element type followed by a pair of square brackets followed by the variable name. The square brackets signify that the variable is an array. For example to declare an array of int variables called pins you would write int pins Personal Identification Numbers Microsoft Visual Basic programmers should note that you use square brackets and not parentheses. C and C programmers should note that the size of the array is not part of the declaration. Java programmers should note that you must place the square brackets before the variable name. NOTE You are not restricted to primitive types as array elements. You can also create arrays of structs enums and classes. For example to create an array of Time structs you would use Time times TIP It is useful to give array variable plural names such as places where each element is a Place people where each element is a Person or times where each element is a Time . Creating Array Instances Arrays are reference types regardless of the type of their elements. This means that an array variable refers to an array instance on the heap just as a class variable refers to an object on the heap and does not hold its array elements directly on the stack as a struct does . To review values and references and the differences between the stack and the heap see Chapter 8 Understanding Values and References. Remember that when you declare a class variable memory is not allocated for the object until you create the instance by using new. Arrays follow the same rules when you declare an array variable you do not .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.