Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
3Activity
0 of .
Results for:
No results containing your search query
P. 1
Java Lecture 2

Java Lecture 2

Ratings: (0)|Views: 5|Likes:
Published by Saurabh Kumar

More info:

Published by: Saurabh Kumar on Sep 25, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

06/01/2013

pdf

text

original

 
1
Computer Science and Elementsof Programming
Java Lecture 2
Dr Giovanna Di MarzoSerugendo
Department of Computer Scienceand Information SystemsBirkbeck College, University of LondonEmail: dimarzo@dcs.bbk.ac.ukWeb Page:http://www.dcs.bbk.ac.uk/~dimarzo
 
Java Lectures Giovanna Di Marzo Serugendo2
Java Lecture 1: Review
Program editing/ compiling/ executingProgram editing/ compiling/ executingin BlueJString Variables
 –Declaration –Assignment
Inputs/Outputs
 –Inputs –Outputs to a terminal window
Inputs/Outputs in BlueJ
 
2
Java Lectures Giovanna Di Marzo Serugendo3
Java Lecture 2: Overview
Java Primitive types (numericalvalues)
 –Type
byte
 –Type
short
 –Type
int
 –Type
long
 –Type
float
 –Type
double
Values Range and OperatorsVariables
 –Declarations, Assignments, I/O
WorkingwithoperatorsTypes conversion
Java Lectures Giovanna Di Marzo Serugendo4
Primitive Types vs Objects
In Java everythingisan object….
exceptvariables whosetype isa
Primitive Type
Values for thosevariables are: –Arithmetic/ Numericalvalues: 3.14, 55, -27, 0.0004, … –Booleanvalues: true, false / 1, 0 –Characters: ‘a’, ‘b’,‘_’, ‘2’, ‘A’,
 
3
Java Lectures Giovanna Di Marzo Serugendo5
Primitive Types: NumericalValues
Types for numericalvalues
 –Integers(-3, 0, 1, 5500, -29567, …)
Type
byte
Type
short
Type
int
Type
long
 –Real numbers(0.0, -23.45, 4.67093)
Type
float
Type
double
Java Lectures Giovanna Di Marzo Serugendo6
Integers
Differentsizes
 –differentsizes(# bits)allocatedin memoryfor storingthe value
differentrange of possible valuesRange# bitsType
-9223372036854775808 to 922337203685477580764 bits
long
-2147483648 to 214748364732 bits
int
-32768 to 3276716 bits
short
-128 to 1278 bits
byte

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->