Skip to main content
IBM 
ShopSupportDownloads
IBM HomeProductsConsultingIndustriesNewsAbout IBM
Java Language EssentialsDownload tutorial zip fileEmail this tutorial to a friend
Main menuSection menuGive feedback on this tutorialPrevious panelNext panel
Exercises
  


2. Using Java For-Loops: Tasks page 5 of 31


For this exercise you will use a loop to print out some strings and use a nested loop to simulate a multiplication (6*3).

[If you are using IBM's VisualAge for Java for this exercise, then use the scrapbook to type and test your code (without a main() method etc...), thus, avoiding the need to fill in the skeleton code, compile, and run from the command line.].

For more help with exercises, see About The Exercises

Prerequisites
  • None.

Tasks

  • Task 1

    Make a for-loop that prints "Hello" 5 times.

  • Task 2

    Define an integer sum, initializing it to 0.

  • Task 3

    Make a loop that counts from 1 to 6.

  • Task 4

    Make an inner loop, nested within the previous loop, that counts from 1 to 3. The statement of the inner loop should increment sum.

  • Task 5

    Print out the value of sum.

Help for each of these tasks can be found on the next page.


copyright 1996-2000 Magelang Institute dba jGuru


Main menuSection menuGive feedback on this tutorialPrevious panelNext panel
PrivacyLegalContact