9/21/2013 1
CSCI 1101B {101B} 09/19/13 The Golden Lecture
Mohammad T. Irfan
Chapter 2
What’s in a name? Variables
- TYPE
NAME;
- int i;
- int i, j, anotherVar;
- double i, j = 10.37, anotherVar;
- Same as the following two lines:
- double i, j, anotherVar;
- j = 10.37;
- boolean isFound = false;
- char c = ‘x’;
- Why are they called variables?
int num = 10; num = 20;
Constants
- final int NUM = 10;
- Later on, you can’t change the value of NUM
NUM = 20; //Error
Objects
- int num = 5;
- FilledOval circle = new FilledOval (10, 50,100, 100,canvas);
Type (Class): FilledOval Name (Object): circle Value: constructor Type: int Name: num Value: 5