Untitled

1 Flashcard Deck

Untitled (Press 'Tab' to generate using AI)
Scholarly automatically converts large note blocks into toggleable sections.
Note taking is extremely easy, simply just click 'Enter' at the end of a line to add another line.
Press 'Tab' to create indents/sub notes.
You can have infinite indents, and each indent will create a toggleable note.
You can even move each line by clicking the 9 Dots to the left of a line.
Data Types
Programs and CPUs work with values, values are represented in programs by literals and stored in variables 
Literal: “Hello There,” true, -23, etc.
Upload an image or PDF
Variables: x, y, helloMessage, etc. (use letters, digits and underscore, start with letter, identifies a location in memory)
Variables/Literals have types
int: Subset of integers, stored in 4 bytes (32 bits), variables declared with “int” are reserved work
Set of OperationsL +, -, *, / and % (mod), remainder 17%3 = 2
Primitive Types: built into language (boolean, byte, short, int, float, float, double, char)
Occupy enough bits to store the value
Reference Types
Can be defined by the user
Hold a “reference” (pointer) to an object
String Type
Set of values: sequences of characters length - to 2,147,483,647
Set of operations: concat() (also + operator), toUpperCase(), length(), substring()
String are immutable, can’t change a string once set
Primitive stores actual value, reference stores address
Variable: memory location where something can be stores, contents of the location can change/vary
Literal: Value cannot be changed, stored in a variable
Declarations
Variables but be declared and given a type
Compiler arranged space to be allocated for the variable to store a value, ensures only valid operations can be performed for given type
Primitive Types
Integer Types in Java
All represent subsets on integers, differs in how many bits used to store the value
Byte: 9 bits (-128 to 127)
Short: 16 bits (-32,768 to 32,767)
int: 32 bits (what’s used in CS 180)
long: 64 bits (18 digits)
Operations on Integer Divide
Mathematical operations
Divide operation is “integer divide,” results in integer regardless of actual solution, called truncation, drops everything after decimal point (13 / 4 is 3)
Real Number Types in Java
Represent subsets of real numbers
Two types, floats (32 bits, single precision) and doubles (64 bits, double precision), 16 bits for exponent, 48 or so for number, double uses bigger/smaller decimals and larger numbers/digits possible so “double precision”
Operations on Real Types
Usual mathematical operations, divide gives actual decimal
Math Class includes other methods (some applicable to integers)
Math.pow(Base, exponent)
Logs, trig, etc.
Declarations
int x; (declare only, 0 by default)
int x = 5; (declare and initialize)
int x, y; (dual declaration)
int x = 5, y = 10; (dual initialization)
Best practice is to declare only one variable per line with comment describing variable
Expressions
Combining variables and literals with operators (+, -, etc)
Usual mathematical precedence, multiplications and division first, addition and subtraction next
Usual mathematical precedence: multiplications and division first, addition and subtraction next.

Scholarly Assistant's Insights

Automatically toggle notes for easy note-taking, learn about data types, primitive and reference types.
Java
Programming
Data Types
Variables
Primitive Types
+8 more

Similar Pages

Login to Leave a Comment

Give your feedback, or leave a comment on a page to share your thoughts with the community.