38e3 Java - Loops and Conditional Statements
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Java module J704
Loops and Conditional Statements
Exercises, examples and other material relating to training module J704. This topic is presented on public courses Learning to Program in Java, Java Bootcamp, Java Programming for the Web

Unless otherwise specified, code runs from top to bottom, very much in the manner that you read a book. Conditional statements such as "if" allow the programmer to choose whether or not blocks of the code are to be skipped over, and loops such as "while" allow blocks of code to be repeated.

Related technical and longer articles
Solution Centre - all article listing
Solution Centre - all article listing

Articles and tips on this subjectupdated
3397Does a for loop evaluate its end condition once, or on every iteration?
All the languages that we teach have a for loop or the equivalent, which is a clean way of repeating a block of code with a rising or falling index number. It's used in many circumstances - for example in iterating through the months of the year (for m goes from 1 to 12) of in stepping through all ...
2012-04-15
 
3200How a for loop works Java, Perl and other languages
Java, Perl, PHP, Ruby, C, C++, Tcl and many other languages support a "for" loop construct. When your program enters the top of the loop, it performs the first statement in the brackets ... in this Perl example, that's to initialise the $now variable to 1. It then evaluates the expression given as ...
2011-03-18
 
3038Setting 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 ...
2010-11-09
 
2734for and foreach in Java
Java has had a "traditional" for loop from the beginning:   for (int k=0; k<Allwords.size(); k++) { That's three semicolon separated elements: • initial setting • test to see if loop should continue • action to be taken before each re-test So that when that's used in a loop ...
2010-04-23
 
1696Saying NOT in Perl, PHP, Python, Lua ...
"Isn't there one standard way to say NOT?" asked one of my delegates on today's course - and it's an excellent question. But the answer to a question about a negative subject is itself in the negative - no, there isn't just a single way! In fact .. I can think of no fewer that 12 ways! • 1. ! ...
2008-07-05
 
1582Ruby, C, Java and more - getting out of loops
break and continue statements have been available for loop control for many years, and others functionallity has been added such as Perl's redo. From today's Ruby Course, here's a table that compares these loop controls in Ruby to similar commands in the other languages that I have been discussing ...
2008-03-19
 
1220for loop - how it works (Perl, PHP, Java, C, etc)
When writing a program, you'll often want to repeat a block of code, counting up through a table or performing a block of code with an input value (loop counter) that goes up 1, 2, 3, 4 etc. You COULD do this using a while loop, but this means you have to specify each of • how to start (initialise) ...
2007-06-07
 
353Wimbledon Neck
What use is the "+=" operator? Why did the language designers bother to provide it? Yet they did ... In Perl and PHP $number_on_bus = $number_on_bus + $goton_here; becomes $number_on_bus += $goton_here; In Python number_on_bus = number_on_bus + goton_here becomes number_on_bus += goton_here In ...
2006-06-05
 
2275
Examples from our training material
Bills.java   Nested loops, conditionals, breaks, labels etc
Day2a.java   Sample program for exercise
Firstif.java   Example of a first if statement
Forloop.java   the 'for' loop in Java
Loop1.java   'While' loop example
Loop2.java   Breaking from a loop
Newtab.java   First read - calculate - loop program
Secondif.java   Nested 'ifs', and 'else'
Updown.java   Example of a boolean variable
Pictures
Studying Java!
Background information
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
Booleans.
"if" statement.
"while" loop.
"for" loop.
Labels and breaks.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Java,Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses 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.


You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2013: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/J704.html • PAGE BUILT: Wed Mar 6 10:39:20 2013 • BUILD SYSTEM: wizard
0