CS 1410 Lecture 2: Components of Code and Variables Intro

45 views2 pages

Document Summary

Components of code (1) variables (2) assignment (3) expressions. Variables; storage locations int number = 0; int elapsedtimeinseconds; Give good names to variables, so they are easier to read: naming variables, the first word isn"t capitalized, continued words are capitalized with no spaces, every variable has. 4) scope; where in the program a variable can be used. 5) lifetime; when does it begin existence and when is the information lost. The variable is gone after the main method (within braces {}), or gone within other pair of braces {: types of variables. Assignment; giving values to a variable int size; //declaration of a variable int x, y; //declaring multiple variables at once: size = 42; //assigning a value to the variable. Expressions; any portion of a java statement that computes a value of some type int t = 4 + 3: operations with different variable types results in the most broad type.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents