Java for WebObjects Developers-P2

Tham khảo tài liệu 'java for webobjects developers-p2', 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-P2 You can nest code to avoid creating variables Often you need to create an object merely for the purpose of giving it to another object. You don t need your own reference variable in the meantime. Java syntax allows you to nest the code for creating an object within the list of arguments you are sending to another object s method. Create it pass it and forget about it all in one statement. In a similar spirit you often need to send a message to get an object then immediately send a message to that object to get what you re really after. For example assume you need the name of the customer that owns the shopping cart. You could create a temporary variable to hold the intermediate object Customer customer String name But in this case you are interested in the name not the customer. Java syntax allows you to connect multiple messages into a single expression where each subsequent message is sent to the return value of the previous String name .lastName To generalize wherever you need to supply an object reference you can supply any expression that returns an object reference. Java for WebObjects Developers Chapter 2 23 Character strings are objects Character strings are instances of the class String String name You can use literal strings String banner All widgets on sale John You can concatenate strings with the operator String fullName John Doe Customer s fullName Strings are immutable once created you cannot change their value Character strings are objects Java represents character strings as objects. They are instances of the class named String. Strings are simple values and are used to represent basic object attributes. Because they are so common convenient handling of strings is built into the Java language itself. You can use a literal string value in quotes as an alternative to constructing a string object .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂ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.