Class Notes (1,100,000)
US (490,000)
Cornell (1,000)
CS (100)
CS 2110 (30)
Gries (30)
Lecture 2

CS 2110 Lecture 2: Objects


Department
Computer Science
Course Code
CS 2110
Professor
Gries
Lecture
2

This preview shows page 1. to view the full 4 pages of the document.
Lecture 2 - Objects
Like in Python, parameter is the variable inside a method
Argument is when you call the method
Creating a new object
new javax.swing.JFrame()
This is just an example
Creates a JFrame Object.
Value of this expression is a pointer to the new object
JFrame@25c7f37d for example is the value
Example
First write javax.swing.JFrame h;
This lets us know the type for h
Then write h = new javax.swing.JFrame()
Now the object name is stored in h
Note: Procedure is a method that does not return a value
To call methods from outside, you do h.<method>()
Specifications BEFORE you write class definition.
NOT LIKE PYTHON
&^^^^^^^^
^^^^
REMEMBER THAT
Note: You’re delaratio of our ariale a e ade shorter  oiig the
two lines
Remember for an int
Int x;
x = 5
Now we can combine the two
int x = 5
So for class definitions, if we want to make something of class CC for example
CC g= new CC();
Creates variable g, stores the object of type CC’s ae i g
Subclasses
If we do public class CC extends javax.swing.JFrame {...}
We get C as a subclass of JFrame
WOAAAAAAAAAAAAAAAH
Declaring methods in class definitions
find more resources at oneclass.com
find more resources at oneclass.com
You're Reading a Preview

Unlock to view full version