CSCI 1006 Lecture Notes - Lecture 3: Null Character, Memory Address
33 views4 pages
21 Sep 2016
School
Department
Course
Professor
● Primitive variables
● must be given a value before being used, which is known as initialization.
● For example, int x = 10 sets the value of x to 10.
● Objects must be instantiated, or an instance of it must be created.
● A constructor is used for this purpose.
■ “new” is the keyword used to construct.
● A variable is used to identify memory.
● It is initially null.
● After instantiation, it refers to a particular piece of memory.
● An object is necessary to call a method.
● “.” is used, meaning member-of operation.
■ z.teach( ), for example. Teacher z uses the teach method here.
● String is a preset Java class.
● A string is a group of 1 or more characters.
● Even though it is not a primitive, a string can be initialized.
■ Strings can be combined with +.
■ For example, a = b + “hi.” Or, a = “my” + pin will put the number into the string.
● Methods to print strings:
■ System.out.print( ).
■ System.out.println( ).
● When an object is treated as a string, Java will look for a toString( ) method.
■ By default, treating an object as a String results in “<name of class> @
<memory address>.
● The scope for a parameter variable is in the method itself.
● It will cease to exist outside that variable.
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document
This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.
Already have an account? Log in
Document Summary
Must be given a value before being used, which is known as initialization. For example, int x = 10 sets the value of x to 10. Objects must be instantiated, or an instance of it must be created. A constructor is used for this purpose. A variable is used to identify memory. After instantiation, it refers to a particular piece of memory. An object is necessary to call a method. A string is a group of 1 or more characters. Even though it is not a primitive, a string can be initialized. For example, a = b + hi. or, a = my + pin will put the number into the string. When an object is treated as a string, java will look for a tostring( ) method. By default, treating an object as a string results in @ The scope for a parameter variable is in the method itself.
Get access
Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers