Java for WebObjects Developers-P3

Tham khảo tài liệu 'java for webobjects developers-p3', công nghệ thông tin, quản trị web phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Java for WebObjects Developers-P3 NSArray useful methods You often get a pre-constructed NSArray from other objects. For example a shopping cart might define a method to return all items in an NSArray. Instances of NSArray are constant you cannot add or remove objects but you can access the existing objects. You can find out how many objects are in an NSArray using the count method. You retrieve an object using an index value an integer as the argument to objectAtIndex . Recall that if you attempt to retrieve an object using an invalid index the NSArray will generate an out of bounds exception. You can also ask an NSArray if it contains a specific object and if so retrieve its index value with indexOfObject . NSArray access methods are defined to return a generic object reference Object . If you need to treat an object from an array more specifically you must use a cast. Unlike many arrays in traditional languages NSArray can store objects of any type they do not all have to be the same class of object. NSArray can only store objects not primitive types like int or double. You cannot store a null. The NSArray class defines many additional methods. The methods shown here comprise a useful subset. Consult the WebObjects foundation documentation for details. Note in particular the various frequently overlooked constructor methods which you can use to create an NSArray containing for example a single object or a collection of objects in a Java native array. Java for WebObjects Developers Chapter 2 43 NSMutableArray useful methods Constructing a new mutable array NSMutableArray items new NSMutableArray Adding an object widget Removing an object widget Creating a new mutable array from an existing immutable array NSArray items NSMutableArray items2 new NSMutableArray items NSMutableArray useful methods An NSMutableArray responds to the same messages as an NSArray. You can determine the count of objects in the array

Không thể tạo bản xem trước, hãy bấm tải xuống
Đã 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.