JavaReview - JAVA REVIEW Variable Declaration Variable...

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

J 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 (==, !=) AND (&&) 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.
Image of page 1

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

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern