You are on page 1of 3

1

1.00 Tutorial 1
Introduction to 1.00
Outline
? Introductions
? Administrative Issues
? PS#0
? PS#1
?Java? Fundamentals
2
Introductions
? T A & s tudents introduce yourselves
? Name
? Y ear
? P leas e s ign attendance s heet
? P artner ass ignments
Office Hours
?Office hours are held thrice / week
?F eel free to come with questions about J ava?,
software, or homework, but...
? Don't come in if you need homework help, and
you have not serious ly tried to do it on your own.
Y ou will be asked to leave.
? T utorial S ections: if you need to s witch s ections ,
send email.
3
Course Website
? Certificate problems?
? Have you installed MIT personal certificates?
? Use Netscape instead of Internet Explorer
?For "unknown SSL error (-12227)":
? uninstall Netscape
? delete profile folder* (backup bookmarks first)
? download and install Netscape 7 from web
? get MIT site certificate and MIT personal
certificates (see instructions on course website)
*See http://wp.netscape.com/eng/mozilla/ns62/CCKDocs/profile_appx_cck.htm
for the path to the profile directory under different operating systems
Laptop Problems
?See MIT website for where to go for software
/hardware problems.
4
Forte: Basics
? Startup (just double-click once and wait!)
?Make sure the Java? SDK 1.4 API
documentation is installed. If not, get from
http://java.sun.com/j2se/1.4/download.html
(Scroll down to documentation section.)
? To check, type the word "String" in the
Source Editor, right click, and select
"Show Javadoc"
PS #0
? Problem 2: Hand In
? Problem 3: Hello World (get checked off)
? Problem 4: Upload file to your 1.00
homework locker (get checked off)
? Problem 5: set up printing in Forte
? set up Athena printer
5
PS#1: in class exercise
? declare a variable
? assign a value to a variable
? what is a floating point number?
? what is a float? a double?
? boolean?
? assign a value to a boolean
? what is a String?
? print a string
Math: more exercises
? Declare two ints, add them and print the
result
? Print out the square root of 2
? Print out (pi to the square root of 2)
? What is the value of the following
expressions (as integers)?
1 % 3
7 % 3
1 / 2
3 / 2
a0
a1
6
Java? Variables
? have a type
? are case sensitive (studentCount is
different from studentcount)
? begin with a letter, underscore, or $:
i, _tmp, $x
?cannot be Java? keywords. The following
are not legal variable names:
for, goto, import, while, do,...
Java? Fundamental Types
type bits
? boolean (true or false) 1
? byte 8
? char 16
? short 16
? int 32
? long 64
? float 32
? double 64
7
Examples
int studentCount = 91;
char firstLetter = 'a';
float weight = 180.6F;
double area = Math.PI * 5.0 * 5.0;
boolean enjoy1.00 = true;
boolean xGreaterThanY = x > y;
long theNumberOne = 1L;
double googol = 1E100; /* 10100 */
Conversion between types
? Implicit (automatic) conversion is called
promotion:
double x = 3.1415 + 2;
? Explicit conversion is called casting
int myAge =
(int)(Math.PI*10.0+4.0);
int promoted to double
this expression is a double (very accurate)expression cast to int
8
Type Conversion
? You will need to perform type conversion
often
? Watch out for promotion: very common
source of (hard-to-find) bugs
? Safer to use casting
Promotion rules
Data Type Allowed Promotions
double None
float double
long float,double
int long,float,double
char int,long,float,double
short int, long,float,double
byte short,int,long,float,doublea2 a3a4
a5a6a7
a8
a2 a3a9
a10
a5a6
a4
a2
a8
a2 a11
a3

You might also like