Java, Part 2 - ART of COMPUTING Week 7 Variables Operators...

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

View Full Document Right Arrow Icon
by Assist. Prof. M. Şükrü Kuran ART of COMPUTING Week 7: Variables & Operators
Image of page 1

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

View Full Document Right Arrow Icon
Part 3: Variables & Constants
Image of page 2
VARIABLES Variables are extremely important and key elements to any program. They define memory devices or storage places to keep “ values ” in the program . What is a variable? <variable type><variable name>; int number = 45;
Image of page 3

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

View Full Document Right Arrow Icon
VARIABLES 1. Variable Type When we declare a variable, we clearly specify its type (e.g., integer, double, char). The type of a variable do NOT change through the program. 2. Variable Name A variable has a well-defined name. Variable names do NOT change through the program. NO TWO variables can have the same name (unless scopes are involved). 3. Value The value that the variable stores inside. The value of the variable CAN change over time based on the program. Features of Variables
Image of page 4
VARIABLES Example NOTE : When you declare a variable, you MUST initialize them (i.e., give them their first values.) Example: Check the various variable declaration examples.
Image of page 5

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

View Full Document Right Arrow Icon
VARIABLE NAMING 1. They must consist of LETTERS & DIGITS. Also, the underscore character '_' and dollar sign ‘$’ can be used. 2. You can also use non-English (i.e., Turkish) characters in variable names. 3. The names of variables MUST begin with letters. It is also possible to begin with ‘_’ or ‘$’, but it is not recommended since library routines often use such names.
Image of page 6
Image of page 7
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