Tribes (Int)

After the last major migration into the British Isles, new migrants continued to arrive from mainland Europe. Dozens and dozens of tribes formed.

Forest

Here is a list of just five of the tribes.

  1. Silures
  2. Dubunni
  3. Belgae
  4. Regni
  5. Parisi

 

Since you now have integers to deal with you can use a variable type called int.

 

This code illustrates the use of the int variable.

    1. /**
      *This is the way to make a
      *multi line comment.
      */
    2. class Tribes {
    3. public static void main(String[] args) {
    4. String tribestatement;
    5. tribestatement = "Here is a list of just five of the tribes.";
    6. int tribenumber1 = 1;
    7. int tribenumber2 = 2;
    8. int tribenumber3 = 3;
    9. int tribenumber4 = 4;
    10. int tribenumber5 = 5;
    11. System.out.println(tribestatement);
    12. System.out.println();
    13. System.out.println(tribenumber1 + ". Silures");
    14. System.out.println();
    15. System.out.println(tribenumber2 + ". Dubunni");
    16. System.out.println();
    17. System.out.println(tribenumber3 + ". Belgae");
    18. System.out.println();
    19. System.out.println(tribenumber4 + ". Regni");
    20. System.out.println();
    21. System.out.println(tribenumber5 + ". Parisi");
    22. }
    23. }


Java code

Use Save As to save the code to your folder as: Tribes.java. Then compile the code in the Command prompt window. Use javac Tribes.java to create the .class file. Execute the program. Use java Tribes to run the program.

 

Your output should look like this:

c:\javamike>java Tribes

Here is a list of just five of the tribes'

1. Silures
2. Dubunni
3. Belgae
4. Regni
5. Parisi

< Migrations (Strings) Invaders (Array) >