JavaReview - JAVA REVIEW Variable Declaration Variable types Syntax int(integer 1 2 3 double(floating point 1.1 2.3 3.4 string(words hello world

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
AVA R EVIEW Variable Declaration Variable types: int (integer 1, 2, 3), double (floating point 1.1, 2.3, 3.4) , string (words “hello world”), Boolean (true/false) Syntax: type variableName ; Array declaration (1-D): Syntax: type [] variableName = new type [size] Alt: type [] variableName = new type {1, 2, 3} Array declaration (2-D); Syntax: type [] [] variableName = new type [row size] [column size] Hint: to remember which number goes in which box ([] []) think of the numbers in the order of a coordinate system (e.g. (2, 5) is the 2 nd row and 5 th column. Order of Operations (precedence) Order from highest priority to lowest priority: Casting (converting from one data type to another, e.g. (int) 5.2 returns 5 as an integer) Parenthesis Division and multiplication (*, /, %, remember the % returns the remainder of a division) Addition and subtraction Relational comparison ( > < >= <= etc. etc.) Equality (==, !=) OR (||) Assignment ( variable = value ) General Java programming syntax Function Syntax Print line of text System.out.println (“insert text here”); Print line of text w/o going to next line System.out.print (“insert text here”); Condition statement If ( variable == value ) { insert operations here } Note: == may be replaced by any comparison operator (==, >=, <=) Alternative condition statement else if ( variable == value ) { insert operations here } Note: addition ‘if’ statement is optional if you don’t need it, if you put many if, else statements within each other, it is called a nestled condition statement. e.g.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/01/2010 for the course APPLIED SC 142 taught by Professor Professorstansimmons during the Winter '10 term at Queens University.

Page1 / 4

JavaReview - JAVA REVIEW Variable Declaration Variable types Syntax int(integer 1 2 3 double(floating point 1.1 2.3 3.4 string(words hello world

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online