🗊Презентация Lesson 5. Working with Objects

Нажмите для полного просмотра!
Lesson 5. Working with Objects, слайд №1Lesson 5. Working with Objects, слайд №2Lesson 5. Working with Objects, слайд №3Lesson 5. Working with Objects, слайд №4Lesson 5. Working with Objects, слайд №5Lesson 5. Working with Objects, слайд №6Lesson 5. Working with Objects, слайд №7Lesson 5. Working with Objects, слайд №8Lesson 5. Working with Objects, слайд №9Lesson 5. Working with Objects, слайд №10Lesson 5. Working with Objects, слайд №11Lesson 5. Working with Objects, слайд №12Lesson 5. Working with Objects, слайд №13Lesson 5. Working with Objects, слайд №14Lesson 5. Working with Objects, слайд №15Lesson 5. Working with Objects, слайд №16Lesson 5. Working with Objects, слайд №17Lesson 5. Working with Objects, слайд №18Lesson 5. Working with Objects, слайд №19Lesson 5. Working with Objects, слайд №20Lesson 5. Working with Objects, слайд №21Lesson 5. Working with Objects, слайд №22Lesson 5. Working with Objects, слайд №23Lesson 5. Working with Objects, слайд №24Lesson 5. Working with Objects, слайд №25Lesson 5. Working with Objects, слайд №26Lesson 5. Working with Objects, слайд №27Lesson 5. Working with Objects, слайд №28Lesson 5. Working with Objects, слайд №29Lesson 5. Working with Objects, слайд №30Lesson 5. Working with Objects, слайд №31Lesson 5. Working with Objects, слайд №32Lesson 5. Working with Objects, слайд №33Lesson 5. Working with Objects, слайд №34Lesson 5. Working with Objects, слайд №35Lesson 5. Working with Objects, слайд №36Lesson 5. Working with Objects, слайд №37Lesson 5. Working with Objects, слайд №38Lesson 5. Working with Objects, слайд №39Lesson 5. Working with Objects, слайд №40Lesson 5. Working with Objects, слайд №41Lesson 5. Working with Objects, слайд №42Lesson 5. Working with Objects, слайд №43Lesson 5. Working with Objects, слайд №44Lesson 5. Working with Objects, слайд №45

Содержание

Вы можете ознакомиться и скачать презентацию на тему Lesson 5. Working with Objects. Доклад-сообщение содержит 45 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1





Lesson 5
Working with Objects
Описание слайда:
Lesson 5 Working with Objects

Слайд 2





Objectives

After completing this lesson, you should be able to:
Declare, instantiate, and initialize object reference variables 
Compare how object reference variables are stored in relation to primitive variables 
Access fields on objects 
Call methods on objects 
Create a String object 
Manipulate data by using the String class and its methods 
Manipulate data by using the StringBuilder class and its methods 
Use the Java API documentation
to explore the methods of a
foundation class
Описание слайда:
Objectives After completing this lesson, you should be able to: Declare, instantiate, and initialize object reference variables Compare how object reference variables are stored in relation to primitive variables Access fields on objects Call methods on objects Create a String object Manipulate data by using the String class and its methods Manipulate data by using the StringBuilder class and its methods Use the Java API documentation to explore the methods of a foundation class

Слайд 3





Topics
Declaring, instantiating, and initializing objects
Working with object references
Using the String class
Using the Java API documentation
Using the StringBuilder class
Описание слайда:
Topics Declaring, instantiating, and initializing objects Working with object references Using the String class Using the Java API documentation Using the StringBuilder class

Слайд 4





Working with Objects: Introduction
Objects are accessed via references.
Objects are instantiated versions of their class.
Objects consist of attributes and operations:
In Java, these are fields and methods.
Описание слайда:
Working with Objects: Introduction Objects are accessed via references. Objects are instantiated versions of their class. Objects consist of attributes and operations: In Java, these are fields and methods.

Слайд 5





Accessing Objects by Using a Reference
Описание слайда:
Accessing Objects by Using a Reference

Слайд 6





Shirt Class
Описание слайда:
Shirt Class

Слайд 7





Topics
Declaring, instantiating, and initializing objects
Working with object references
Using the String class
Using the Java API documentation
Using the StringBuilder class
Описание слайда:
Topics Declaring, instantiating, and initializing objects Working with object references Using the String class Using the Java API documentation Using the StringBuilder class

Слайд 8





Working with Object Reference Variables

Declaration:
  Classname identifier;
Описание слайда:
Working with Object Reference Variables Declaration: Classname identifier;

Слайд 9





Declaring and Initializing: Example
Описание слайда:
Declaring and Initializing: Example

Слайд 10





Working with Object References
Описание слайда:
Working with Object References

Слайд 11





Working with Object References
Описание слайда:
Working with Object References

Слайд 12





Working with Object References
Описание слайда:
Working with Object References

Слайд 13





References to Different Objects
Описание слайда:
References to Different Objects

Слайд 14





References to Different Object Types
Описание слайда:
References to Different Object Types

Слайд 15





References and Objects In Memory
Описание слайда:
References and Objects In Memory

Слайд 16





Assigning a Reference to Another Reference
Описание слайда:
Assigning a Reference to Another Reference

Слайд 17





Two References, One Object
Описание слайда:
Two References, One Object

Слайд 18





Assigning a Reference to Another Reference
Описание слайда:
Assigning a Reference to Another Reference

Слайд 19





Quiz
Which of the following lines of code instantiates a Boat object and assigns it to a sailBoat object reference?
Boat sailBoat = new Boat();
Boat sailBoat;
Boat = new Boat()
Boat sailBoat = Boat();
Описание слайда:
Quiz Which of the following lines of code instantiates a Boat object and assigns it to a sailBoat object reference? Boat sailBoat = new Boat(); Boat sailBoat; Boat = new Boat() Boat sailBoat = Boat();

Слайд 20





Topics
Declaring, instantiating, and initializing objects
Working with object references
Using the String class
Using the Java API documentation
Using the StringBuilder class
Описание слайда:
Topics Declaring, instantiating, and initializing objects Working with object references Using the String class Using the Java API documentation Using the StringBuilder class

Слайд 21





String Class

The String class supports some non-standard syntax
A String object can be instantiated without using the new keyword; this is preferred:

String hisName = "Fred Smith";
The new keyword can be used, but it is not best practice:
String herName = new String("Anne Smith");
A String object is immutable; its value cannot be changed.
A String object can be used with the string concatenation operator symbol (+) for concatenation.
Описание слайда:
String Class The String class supports some non-standard syntax A String object can be instantiated without using the new keyword; this is preferred: String hisName = "Fred Smith"; The new keyword can be used, but it is not best practice: String herName = new String("Anne Smith"); A String object is immutable; its value cannot be changed. A String object can be used with the string concatenation operator symbol (+) for concatenation.

Слайд 22





Concatenating Strings

When you use a string literal in Java code, it is instantiated and becomes a String reference
Concatenate strings:

String name1 = "Fred" 
theirNames = name1 + " and " +
             "Anne Smith";
The concatenation creates a new string, and the String reference theirNames now points to this new string.
Описание слайда:
Concatenating Strings When you use a string literal in Java code, it is instantiated and becomes a String reference Concatenate strings: String name1 = "Fred" theirNames = name1 + " and " + "Anne Smith"; The concatenation creates a new string, and the String reference theirNames now points to this new string.

Слайд 23





Concatenating Strings
Описание слайда:
Concatenating Strings

Слайд 24





Concatenating Strings
Описание слайда:
Concatenating Strings

Слайд 25





Concatenating Strings
Описание слайда:
Concatenating Strings

Слайд 26





String Method Calls with Primitive Return Values
A method call can return a single value of any type.
An example of a method of primitive type int:
String hello = "Hello World";
int stringLength = hello.length();
Описание слайда:
String Method Calls with Primitive Return Values A method call can return a single value of any type. An example of a method of primitive type int: String hello = "Hello World"; int stringLength = hello.length();

Слайд 27





String Method Calls with Object Return Values
Method calls returning objects:

String greet = " HOW ".trim();

String lc = greet + "DY".toLowerCase();
	Or
String lc = (greet + "DY").toLowerCase();
Описание слайда:
String Method Calls with Object Return Values Method calls returning objects: String greet = " HOW ".trim(); String lc = greet + "DY".toLowerCase(); Or String lc = (greet + "DY").toLowerCase();

Слайд 28





Method Calls Requiring Arguments
Method calls may require passing one or more arguments:
Pass a primitive

String theString = "Hello World";
String partString = theString.substring(6);
Pass an object

boolean endWorld = 
           "Hello World".endsWith("World");
Описание слайда:
Method Calls Requiring Arguments Method calls may require passing one or more arguments: Pass a primitive String theString = "Hello World"; String partString = theString.substring(6); Pass an object boolean endWorld = "Hello World".endsWith("World");

Слайд 29





Topics
Declaring, instantiating, and initializing objects
Working with object references
Using the String class
Using the Java API documentation
Using the StringBuilder class
Описание слайда:
Topics Declaring, instantiating, and initializing objects Working with object references Using the String class Using the Java API documentation Using the StringBuilder class

Слайд 30





Java API Documentation
Consists of a set of webpages;
Lists all the classes in the API
Descriptions of what the class does
List of constructors, methods, and fields for the class
Highly hyperlinked to show the interconnections between classes and to facilitate lookup
Available on the Oracle website at:
http://download.oracle.com/javase/7/docs/api/index.html
Описание слайда:
Java API Documentation Consists of a set of webpages; Lists all the classes in the API Descriptions of what the class does List of constructors, methods, and fields for the class Highly hyperlinked to show the interconnections between classes and to facilitate lookup Available on the Oracle website at: http://download.oracle.com/javase/7/docs/api/index.html

Слайд 31





Java Platform SE 7 Documentation
Описание слайда:
Java Platform SE 7 Documentation

Слайд 32





Java Platform SE 7 Documentation
Описание слайда:
Java Platform SE 7 Documentation

Слайд 33





Java Platform SE 7: Method Summary
Описание слайда:
Java Platform SE 7: Method Summary

Слайд 34





Java Platform SE 7: Method Detail
Описание слайда:
Java Platform SE 7: Method Detail

Слайд 35





System.out Methods
To find details for System.out.println(), consider the following:
System is a class (in java.lang).
out is a field of System.
out is a reference type that allows calling println() on the object type it references.
To find the documentation:
Go to System class and find the type of the out field.
Go to the documentation for that field.
Review the methods available.
Описание слайда:
System.out Methods To find details for System.out.println(), consider the following: System is a class (in java.lang). out is a field of System. out is a reference type that allows calling println() on the object type it references. To find the documentation: Go to System class and find the type of the out field. Go to the documentation for that field. Review the methods available.

Слайд 36





Documentation on System.out.println()
Описание слайда:
Documentation on System.out.println()

Слайд 37





Using the print() and println() Methods

The println method:
System.out.println(data_to_print);
Example:
 System.out.print("Carpe diem ");
   System.out.println("Seize the day");
This method prints the following:
Carpe diem Seize the day
Описание слайда:
Using the print() and println() Methods The println method: System.out.println(data_to_print); Example: System.out.print("Carpe diem "); System.out.println("Seize the day"); This method prints the following: Carpe diem Seize the day

Слайд 38





Topics
Declaring, instantiating, and initializing objects
Working with object references
Using the String class
Using the Java API documentation
Using the StringBuilder class
Описание слайда:
Topics Declaring, instantiating, and initializing objects Working with object references Using the String class Using the Java API documentation Using the StringBuilder class

Слайд 39





StringBuilder Class
StringBuilder provides a mutable alternative to String.
StringBuilder:
Is a normal class. Use new to instantiate.
Has an extensive set of methods for append, insert, delete
Has many methods to return reference to current object. There is no instantiation cost.
Can be created with an initial capacity best suited to need
String is still needed because:
It may be safer to use an immutable object
A class in the API may require a string
It has many more methods not available on StringBuilder
Описание слайда:
StringBuilder Class StringBuilder provides a mutable alternative to String. StringBuilder: Is a normal class. Use new to instantiate. Has an extensive set of methods for append, insert, delete Has many methods to return reference to current object. There is no instantiation cost. Can be created with an initial capacity best suited to need String is still needed because: It may be safer to use an immutable object A class in the API may require a string It has many more methods not available on StringBuilder

Слайд 40





StringBuilder Advantages over String
for Concatenation (or Appending)
String concatenation
Costly in terms of creating new objects
Описание слайда:
StringBuilder Advantages over String for Concatenation (or Appending) String concatenation Costly in terms of creating new objects

Слайд 41





StringBuilder: Declare and Instantiate
Описание слайда:
StringBuilder: Declare and Instantiate

Слайд 42





StringBuilder Append
Описание слайда:
StringBuilder Append

Слайд 43





Quiz
Which of the following statements are true? (Choose all that apply.)
The dot (.) operator creates a new object instance.
The String class provides you with the ability to store a sequence of characters.
The Java API specification contains documentation for all of the classes in a Java technology product.
String objects cannot be modified.
Описание слайда:
Quiz Which of the following statements are true? (Choose all that apply.) The dot (.) operator creates a new object instance. The String class provides you with the ability to store a sequence of characters. The Java API specification contains documentation for all of the classes in a Java technology product. String objects cannot be modified.

Слайд 44





Summary
Objects are accessed via references:
Objects are instantiated versions of their class.
Objects consist of attributes and operations:
In Java, these are fields and methods.
To access the fields and methods of an object, get a reference variable to the object:
The same object may have more than one reference.
An existing object’s reference can be reassigned to a new reference variable.
The new keyword instantiates a new
object and returns a reference.
Описание слайда:
Summary Objects are accessed via references: Objects are instantiated versions of their class. Objects consist of attributes and operations: In Java, these are fields and methods. To access the fields and methods of an object, get a reference variable to the object: The same object may have more than one reference. An existing object’s reference can be reassigned to a new reference variable. The new keyword instantiates a new object and returns a reference.

Слайд 45





Practice for Lesson 5 Overview: 

 In this practice, you create instances of a class and manipulate these instances in several ways. During the practice, you:
Create and initialize object instances
Manipulate object references
 In this practice, you create, initialize, and manipulate StringBuilder objects
 In this practice, you examine the Java API specification to become familiar with the documentation and with looking up classes and methods. 
You are not expected to understand everything you see. 
But as you progress through this course, you will understand more and more of the Java API documentation.
Описание слайда:
Practice for Lesson 5 Overview: In this practice, you create instances of a class and manipulate these instances in several ways. During the practice, you: Create and initialize object instances Manipulate object references In this practice, you create, initialize, and manipulate StringBuilder objects In this practice, you examine the Java API specification to become familiar with the documentation and with looking up classes and methods. You are not expected to understand everything you see. But as you progress through this course, you will understand more and more of the Java API documentation.



Похожие презентации
Mypresentation.ru
Загрузить презентацию