












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An introduction to identifiers and data types in java programming. It covers the rules for naming identifiers, the different primitive types (boolean, char, int, long, float, double), and the differences between int and long, float and double. It also explains the concept of integer division and how to fix it through typecasting.
Typology: Slides
1 / 20
This page cannot be seen from the preview
Don't miss anything!
Emails in office hours, feel free to set up meeting via email JavaScript vs Java?
An identifier is the name of a variable (or object, class, method, etc.) int sum type identifier
Many other languages allow conversion between integer and boolean True = 1 and false = 0 Java does not allow this
int - Whole numbers in the approximate range: -2.14 billion to 2.14 billions ( 9 ) long - Whole numbers in the approximate range: -9.22 quintillion to 9.22 quintillion ( 18 ) Using int is standard (unless you really need more space, for example scientific computing)
float is now pretty much obsolete. double takes twice as much space in the computer and is 1) more accurate and 2) more precise Bottom line: use double (unless for a joke)
Both stored in scientific notation double x = 2858291; Computer's perspective: x = 2.858291e or x = 2.858291 * 10 6
Field of study for (reducing) computer error See: SubtractionError.java Can happen frequently when solving system of linear equations
If you are counting something (money), use int If you are dealing with abstract concepts (physics), use double int doesn't make “rounding” mistakes Non-primitive types exist for both int and double for more expression/precision
int x; double y; x+y int x; int y; x/y Converted to double Not converted (still int)
See: SimpleDivision.java Can be fixed by typecasting: (double)1/