Exercises, examples and other material relating to training module J703. This topic is presented on public courses Learning to Program in Java
, Java Bootcamp
, Java Programming for the Web
Information that's produced by one Java statement and used in later ones is held in variables. In Java, variables must be declared before they are used, and you must specify the type of information they contain. Operations can be performed on variables, and casting can be used to convert information of one type to another.
|Articles and tips on this subject||updated|
|4324||Learning to program - variables and constants|
Further material from our "learning to program in ...." courses ... an introduction to variables and constants
Information - data - needs to be stored in a program between statements. Or rather it needs to be stored in the computer's memory. At the lowest of levels, that's a binary ...
|3917||BODMAS - the order a computer evaluates arithmetic expressions|
What order does a computer program use to evaluate expressions? If I write
2 + 3 * 4 + 5
does it start off, left to right ...
2 + 3 is 5
5 * 4 is 20
20 + 5 is 25
No! it does not, even though the newcomer might think that was the most natural way for ...
|3365||Turning bright delegates into bright and knowledgable ones|
"Bright" does not mean "Knowledgable". Almost without exception, our delegates are bright or very bright. But, by definition, they arrive with us for a training course with a lack of knowlegde. And it's a real joy to be able to pass on that knowledge to them - empowering them so that they leave knowledgable, ...
|3278||Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java.|
Starting with a clean slate. Are variables initisialised, and if so, how? Even with this fundamental question, languages vary considerably.
C and C++
From my (e)mailbag ...
"""In a piece of code we’ve written we declare an array, but we do not fill the elements with values, we assume (dangerous ...
|3041||Java - basic rules for arithmetic, variables and conversion|
Declare - Initialise - use - the sequence for Java variables
• All Java variables must be declared before they are initialised
• All Java variables must be initialised to a value before their current value is used
1. Declare (i.e. define the type of variable and the name
2. Set an initial ...
|3038||Setting up individual variables, and arrays, in Java - some commented examples|
In Java, variables must be defined before they have an initial value assigned to them, and they must have an initial value assigned to them before the value thay contain is used; there's no automatic assumption that a new name is a variable, nor is there an assumption made of what type of data a variable ...
|2153||Class Loading and Variable Conversion in Java|
"Where did you get THAT from?" Ever heard that question? I've asked it of Java sometimes, in wondering where a Java virtual machine has found a class from ... and it's not always obvious.
When loading a class, Java looks at each location given in the CLASSPATH in turn ... and if there are import ...
|1448||Question on division (Java) - Also Perl, PHP, Python ...|
What's the difference between % and /?
/ returns the result of a division
% returns the remainder when you do a division.
Divide 18 by 7 you get 2, with a remainder of 4 (i.e. 4 left over).
so 18/7 give 2, and 18%7 gives 4.
And from Tcl/Tk and Expect... you can see the float v integer considerations ...
|127||Conversion and coercion in Java|
The accuracy and conversion of primitive arithmetic variables in Java is something that I'm questioned on regularly.
Ideally in Java, you'll perform arithmetic on two pieces of data of an identical type, and the result returned will be of the same type. However, if you perform a calculation on two different ...
Examples from our training material
PicturesOn site training in Oxford
This module is available under an Open Training Notes License
for free download from http://www.training-notes.co.uk
Topics covered in this module
First use of variables in Java.
Declaring and initialising variables.
Type casting and conversion.
Reading input from the user.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.