Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 834

Warning: Invalid argument supplied for foreach() in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 835

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 839

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/e5m7uo8vro0d/public_html/mediawiki/includes/MagicWord.php on line 860
The Knowledge Of Sauron's Minions - Huben's Wiki

The Knowledge Of Sauron's Minions

From Huben's Wiki
Jump to: navigation, search
 
Line 1: Line 1:
 +
[[image:Rivendell.jpg]]
 +
 
Welcome to Rivendell!  You have completed your stay at Hogwarts and have come here to study Java even further, to learn the dark secrets of Sauron.
 
Welcome to Rivendell!  You have completed your stay at Hogwarts and have come here to study Java even further, to learn the dark secrets of Sauron.
  
Line 27: Line 29:
 
}
 
}
 
</pre>
 
</pre>
There is only one method, main(), in this RingWraith class: the other statements at the beginning declare '''variables'''.  The five variables here are the most frequently used sorts.
+
There is only one method, main(), in this RingWraith class: the other statements at the beginning declare '''variables'''.  Variables are places where the program can remember information.  You can think of them as like little boxes, or perhaps whiteboards where you can write and erase things you want to remember.  The five variables here are the most frequently used sorts.
  
 
There are many '''basic types''', but here we shall concern ourselves with only four.
 
There are many '''basic types''', but here we shall concern ourselves with only four.
Line 49: Line 51:
 
# Brace-matching Color is tricky.  How do you reveal it in the code?
 
# Brace-matching Color is tricky.  How do you reveal it in the code?
 
# I can hardly see the Type Color in the code.  Click the ellipsis (...) button to the right of Type Color, and change the color to a dark red.  Click Apply and OK.  More visible now?
 
# I can hardly see the Type Color in the code.  Click the ellipsis (...) button to the right of Type Color, and change the color to a dark red.  Click Apply and OK.  More visible now?
# '''Keyword''' means the same as '''reserved word'''.  We have one of these magic words posted on high: which others should we add now?
+
# '''Keyword''' means the same as '''reserved word'''.  Thou shalt prepare a litany (list) of these reserved words for the purposes of further study.
 
# The basic types are also reserved words: what else then should we add to our list of reserved words?
 
# The basic types are also reserved words: what else then should we add to our list of reserved words?
 
# Why shouldn't we add String to the reserved words?
 
# Why shouldn't we add String to the reserved words?
Line 64: Line 66:
 
==(D) Multitudinous Variables==
 
==(D) Multitudinous Variables==
 
As yet we have examined only singular variables.  In mathematical lore, we often use variables that contain multitudes, as in matrices.  In Java, we have row matrices, called '''arrays'''.  Arrays can be of any type.  We specify an array of a type by placing square brackets '[]' after the type.
 
As yet we have examined only singular variables.  In mathematical lore, we often use variables that contain multitudes, as in matrices.  In Java, we have row matrices, called '''arrays'''.  Arrays can be of any type.  We specify an array of a type by placing square brackets '[]' after the type.
* Add 'int[] anArray = {8, 2, 5};' to the variables at the top of RingWraith.
+
* Add 'static public int[] anArray = {8, 2, 5};' to the variables at the top of RingWraith.
 
In math, we would express this as:  
 
In math, we would express this as:  
  
 
anArray = [8 2 5]
 
anArray = [8 2 5]
  
In math, we would use subscripts to specify which of the numbers to select, subscripts from 1 to 3.  But '''in Java subscripts start at zero''' and '''subscripts are numbers within square brackets'''.
+
In math, we would use subscripts to specify which of the numbers to select, subscripts from 1 to 3.  But '''in Java subscripts start at zero''' and '''subscripts are numbers within square brackets'''.  Each number in an array is called an '''element'''.
 
# Add 'System.out.println( anArray[0] + anArray[1] + anArray[2] );' into main().  What does this do?
 
# Add 'System.out.println( anArray[0] + anArray[1] + anArray[2] );' into main().  What does this do?
 
# You might notice that the array was initialized to three values by placing the set of values in curly braces.  Where else have we used curly braces?
 
# You might notice that the array was initialized to three values by placing the set of values in curly braces.  Where else have we used curly braces?
 +
# What is element 2 of the array?
 
# Add another value to the array by putting another number within the curly braces.
 
# Add another value to the array by putting another number within the curly braces.
 
# Change one of the array values by adding this line in main(): 'anArray[1] = -3;'.  Can you write a set of println() to show all the array values, and see which has changed?
 
# Change one of the array values by adding this line in main(): 'anArray[1] = -3;'.  Can you write a set of println() to show all the array values, and see which has changed?
 
# Look ye at the signature of main().  Where is the array in it?  What is it an array of?
 
# Look ye at the signature of main().  Where is the array in it?  What is it an array of?

Latest revision as of 13:33, 20 September 2013

Personal tools
translate