<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ideawaza.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=70.255.0.0%2F16</id>
	<title>IdeaWazaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://ideawaza.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=70.255.0.0%2F16"/>
	<link rel="alternate" type="text/html" href="https://ideawaza.com/wiki/Special:Contributions/70.255.0.0/16"/>
	<updated>2026-09-30T20:57:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://ideawaza.com/index.php?title=Archive:Java_File_IO&amp;diff=30861</id>
		<title>Archive:Java File IO</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=Archive:Java_File_IO&amp;diff=30861"/>
		<updated>2006-11-26T14:46:40Z</updated>

		<summary type="html">&lt;p&gt;70.255.198.170: /* Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File Input/Output is similar to the System.out and System.in that you already have begun using. The only difference is that you read from a file.&lt;br /&gt;
=Files=&lt;br /&gt;
Files are another type of variable. You can make a file like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;File f = new File(&amp;quot;test.txt&amp;quot;)&amp;lt;/pre&amp;gt;&lt;br /&gt;
This does not return an exception if the file doesn&#039;t exist. To check if it does:&lt;br /&gt;
&amp;lt;pre&amp;gt;f.exists()&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will return a boolean.&lt;br /&gt;
&lt;br /&gt;
To check if it a file or directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;f.isFile()&lt;br /&gt;
f.isDirectory()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For a full list of methods you can use, go to http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html&lt;br /&gt;
&lt;br /&gt;
=File Output=&lt;br /&gt;
To write to a file, you can use a FileWriter or a FileOutputStream.&lt;br /&gt;
==FileWriter==&lt;br /&gt;
This class writes strings or char[] to a file. To create one:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
FileWriter fw = new FileWriter(&amp;quot;test.txt&amp;quot;);//Create a filewriter writing to test.txt&lt;br /&gt;
FileWriter fw = new FileWriter(&amp;quot;test.txt&amp;quot;, true);//Do not delete contents of file - append&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
It is as simple to write. After you create a FileWriterm just use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
String s = &amp;quot;Testing&amp;quot;&lt;br /&gt;
//INITIALIZE FileWriter fw&lt;br /&gt;
fw.write(s);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==FileOutputStream==&lt;br /&gt;
=File Input=&lt;/div&gt;</summary>
		<author><name>70.255.198.170</name></author>
	</entry>
	<entry>
		<id>https://ideawaza.com/index.php?title=Archive:Java_File_IO&amp;diff=30860</id>
		<title>Archive:Java File IO</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=Archive:Java_File_IO&amp;diff=30860"/>
		<updated>2006-11-26T14:40:45Z</updated>

		<summary type="html">&lt;p&gt;70.255.198.170: New page: File Input/Output is similar to the System.out and System.in that you already have begun using. The only difference is that you read from a file.
=Files=
Files are another type of variable...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File Input/Output is similar to the System.out and System.in that you already have begun using. The only difference is that you read from a file.&lt;br /&gt;
=Files=&lt;br /&gt;
Files are another type of variable. You can make a file like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;File f = new File(&amp;quot;test.txt&amp;quot;)&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>70.255.198.170</name></author>
	</entry>
	<entry>
		<id>https://ideawaza.com/index.php?title=Basic_Java_Language&amp;diff=36719</id>
		<title>Basic Java Language</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=Basic_Java_Language&amp;diff=36719"/>
		<updated>2006-11-26T14:37:06Z</updated>

		<summary type="html">&lt;p&gt;70.255.198.170: /* Declaring Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This lesson discusses the basics of the Java language, including variables, primitives, operators, statements and Java writing conventions.&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are used to store data that can change. There are two main categories of variables, &#039;&#039;reference variables&#039;&#039; and &#039;&#039;primitive variables&#039;&#039;. Reference variables are place holders for objects (More on objects in Lesson 4, [[Java Objects and Classes]].) Primitive variables are given a value of a primitive, a basic value. Variables are all given a type when they are declared, such as &amp;quot;int&amp;quot; or &amp;quot;string&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Primitive Data Types==&lt;br /&gt;
Primitives are the simplest type of data. Primitives consist of numbers, letters and strings of letters. The following table shows all the types of primitives.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
{| border=1 cellspacing=0 cellpadding=5&lt;br /&gt;
| &#039;&#039;&#039;Primitive&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Description&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Values&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| byte&lt;br /&gt;
| A brief, 8-bit integer&lt;br /&gt;
| Whole numbers -128 through 127&lt;br /&gt;
|-&lt;br /&gt;
| short&lt;br /&gt;
| A short, 16-bit integer&lt;br /&gt;
| Whole numbers -32,768 through 32,767&lt;br /&gt;
|-&lt;br /&gt;
| int&lt;br /&gt;
| A 32 bit integer&lt;br /&gt;
| Whole numbers -2,147,483,648 through 2,147,483,647&lt;br /&gt;
|-&lt;br /&gt;
| long&lt;br /&gt;
| A long, 64 bit integer&lt;br /&gt;
| Whole numbers -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807&lt;br /&gt;
|-&lt;br /&gt;
| float&lt;br /&gt;
| Single-precision floating point (32-bit IEEE 754)&lt;br /&gt;
| Smallest positive non-zero: 14e&amp;lt;sup&amp;gt;-45&amp;lt;/sup&amp;gt;, Largest positive non-zero: 3.4028234e&amp;lt;sup&amp;gt;38&amp;lt;/sup&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| double&lt;br /&gt;
| Double-precision floating point (64-bit IEEE 754)&lt;br /&gt;
| Smallest positive non-zero: 4.9e&amp;lt;sup&amp;gt;-324&amp;lt;/sup&amp;gt;, Largest positive non-zero: 1.797693157e&amp;lt;sup&amp;gt;308&amp;lt;/sup&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| char&lt;br /&gt;
| A single character&lt;br /&gt;
| All Unicode characters&lt;br /&gt;
|-&lt;br /&gt;
| boolean&lt;br /&gt;
| A Boolean value&lt;br /&gt;
| &#039;&#039;&#039;true&#039;&#039;&#039; or &#039;&#039;&#039;false&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declaring Variables==&lt;br /&gt;
In a nutshell, declaring a variable has this syntax:&lt;br /&gt;
&amp;lt;pre&amp;gt; [variable type] [identifier];&amp;lt;/pre&amp;gt;&lt;br /&gt;
This works for both reference variables and primitive variables. [variable type] is the type of variable, like &#039;&#039;&#039;int&#039;&#039;&#039; or &#039;&#039;&#039;char&#039;&#039;&#039;. [identifier] is the name for the variable you wish to create, for example, &#039;&#039;password&#039;&#039; or &#039;&#039;number_of_fish&#039;&#039;. If you wanted to create a &#039;&#039;&#039;int&#039;&#039;&#039; variable called &#039;&#039;age&#039;&#039;, you would type this:&lt;br /&gt;
&amp;lt;pre&amp;gt;int age;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the semicolon at the end of the statement. All statements in Java must end in this, otherwise you will get a compiler error. &lt;br /&gt;
&lt;br /&gt;
You can set the values of variables while declaring them, like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;int age = 100;&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can declare multiple variables on one line, if you wish:&lt;br /&gt;
&amp;lt;pre&amp;gt; boolean a, b;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Also, you can change variables after you already give them a value.&lt;br /&gt;
&amp;lt;pre&amp;gt;[v you want to change] = [v you want it to be];&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Identifiers===&lt;br /&gt;
There are several rules for the naming of your variables. Identifiers can be named using all the letters from A through Z (capital or lowercase, you choose), numbers 0-9 and underscore _ and the dollar sign $. The first character of the identifier cannot be a number, but it can be a letter, _ or $. &lt;br /&gt;
&lt;br /&gt;
You can&#039;t create two variables with the same identifier, all identifiers must be unique. You also can&#039;t use an identifier that is a Java keyword. Here is a list of all the [http://en.wikipedia.org/wiki/Java_keywords Java Keywords].  [[Flashcards for Java keywords]] provides some assistance in memorizing the concepts behind specific keywords.&lt;br /&gt;
&lt;br /&gt;
==Statements==&lt;br /&gt;
A statement in Java is a chunk of code that does something specific completely. Statements are ended by a semicolon ;. An example of a statement is the declaration of a variable like we saw before. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;private int static numberOfObjectsInstantiated;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above declares a single memory location per class which may be incremented each time an object of that class is instantiated by calling its constructor method.&lt;br /&gt;
&lt;br /&gt;
Another example you will recall from the &amp;quot;Hello World&amp;quot; program we made in Lesson 1. &lt;br /&gt;
&amp;lt;pre&amp;gt;System.out.println(&amp;quot;Hello World&amp;quot;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
This line of code prints &#039;&#039;Hello World&#039;&#039; onto the console.&lt;br /&gt;
&lt;br /&gt;
A third example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;if (ourShip.speed&amp;lt;10) then ourShip.mainThrustPulse(2);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above checks a ship object&#039;s speed and if it is less than ten then it commands the ship object to fire two pulses from its main propulsion rockets.  It is a single specific application task completed at the semi-colon when it moves to the next chunk of code.&lt;br /&gt;
&lt;br /&gt;
==Comments==&lt;br /&gt;
Comments are notes that the developer can insert into their code. This allows the developer to keep track of their code and helps when developers are collaborating on a project. It is good to write a summary of the following code at the beginning of your methods, classes, etc. The Java compiler completely ignores comments, so you can say anything in them&lt;br /&gt;
&lt;br /&gt;
Comments are written using two forward slashes&lt;br /&gt;
&amp;lt;pre&amp;gt;//This is a comment&amp;lt;/pre&amp;gt;&lt;br /&gt;
Comments can be written at the end of a line&lt;br /&gt;
&amp;lt;pre&amp;gt;System.out.println(&amp;quot;I love comments&amp;quot;); //This is also a comment&amp;lt;/pre&amp;gt;&lt;br /&gt;
Comments can also be written on multiple lines by starting with &#039;&#039;&#039;/*&#039;&#039;&#039; and ending with&#039;&#039;&#039;*/&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;/* Comment 1&lt;br /&gt;
Comment 2&lt;br /&gt;
Comment 3 */&amp;lt;/pre&amp;gt;&lt;br /&gt;
:Sun recommends the above form be reserved for information intended for automatic JavaDoc documentation.&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
===Assignment Operator = ===&lt;br /&gt;
The assignment operator sets the variable on its left equal to the value on its right. This code creates the variable &#039;&#039;a&#039;&#039; and sets it equal to 5&lt;br /&gt;
&amp;lt;pre&amp;gt;int a;&lt;br /&gt;
a = 5;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Fairly simple, right? Here is where it can get a little more tricky. &lt;br /&gt;
&amp;lt;pre&amp;gt;int a;&lt;br /&gt;
int b;&lt;br /&gt;
b = 6;&lt;br /&gt;
a = b; //a equals 6&amp;lt;/pre&amp;gt;&lt;br /&gt;
At first glance, you might think that the last statement is setting &#039;&#039;a&#039;&#039; equal to the letter &amp;quot;b&amp;quot;, but instead it is setting &#039;&#039;a&#039;&#039; equal to the &#039;&#039;value&#039;&#039; of &#039;&#039;b&#039;&#039;, which is 6.&lt;br /&gt;
&lt;br /&gt;
===Addition Operator +===&lt;br /&gt;
Unlike the = operator, a statement that simply uses the addition operator and two other values on either side does not do anything significant. For example, neither of the following three lines of code do anything.&lt;br /&gt;
&amp;lt;pre&amp;gt;5 + 6;&lt;br /&gt;
a + 9;&lt;br /&gt;
a + b;&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you want to you want to use the addition operator to add 6 to the value of &#039;&#039;a&#039;&#039;, it would be used like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;a = a + 6;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or you can use a shortcut in order to reach the same result as the above.&lt;br /&gt;
&amp;lt;pre&amp;gt;a += 6;&amp;lt;/pre&amp;gt;&lt;br /&gt;
There are shortcuts to all of the operators, which will be shown in the following sections.&lt;br /&gt;
&lt;br /&gt;
===Subtraction -, Division / and Multiplication * Operators===&lt;br /&gt;
&lt;br /&gt;
Just like the addition operator, the Subtraction, Division, and Multiplication operators are used as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int a;&lt;br /&gt;
&lt;br /&gt;
a = a-1;&lt;br /&gt;
a = a/1;&lt;br /&gt;
a = a*1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of &amp;quot;a&amp;quot; in each example would be simply&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1st a - &amp;quot;a&amp;quot; minus 1&lt;br /&gt;
2nd a - &amp;quot;a&amp;quot; divided by 1&lt;br /&gt;
3rd a - &amp;quot;a&amp;quot; multiplied by 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When all of the operators are used at once, for example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int a, b, c, d;&lt;br /&gt;
&lt;br /&gt;
a = a-b/c*d;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You would then use the order or operations, otherwise known as [http://en.wikipedia.org/wiki/PEMDAS PEMDAS], to find the result of &amp;quot;a&amp;quot;; which would be:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a = a - (b/c)d&lt;br /&gt;
or&lt;br /&gt;
         b&lt;br /&gt;
a = a - ---&lt;br /&gt;
       (c*d)&lt;br /&gt;
&lt;br /&gt;
(either way the result is the same)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or if you prefer actual numbers, it would look like so:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int a = 1;&lt;br /&gt;
int b = 2;&lt;br /&gt;
int c = 2;&lt;br /&gt;
int d = 1;&lt;br /&gt;
&lt;br /&gt;
a = 1-2/2*1;&lt;br /&gt;
&lt;br /&gt;
thus:&lt;br /&gt;
&lt;br /&gt;
a = 1 - 1&lt;br /&gt;
or &lt;br /&gt;
a = 0;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;More coming soon&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[Topic:Java|Back to Java Main Page]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>70.255.198.170</name></author>
	</entry>
	<entry>
		<id>https://ideawaza.com/index.php?title=Basic_Java_Language&amp;diff=36718</id>
		<title>Basic Java Language</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=Basic_Java_Language&amp;diff=36718"/>
		<updated>2006-11-26T14:36:47Z</updated>

		<summary type="html">&lt;p&gt;70.255.198.170: /* Declaring Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This lesson discusses the basics of the Java language, including variables, primitives, operators, statements and Java writing conventions.&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are used to store data that can change. There are two main categories of variables, &#039;&#039;reference variables&#039;&#039; and &#039;&#039;primitive variables&#039;&#039;. Reference variables are place holders for objects (More on objects in Lesson 4, [[Java Objects and Classes]].) Primitive variables are given a value of a primitive, a basic value. Variables are all given a type when they are declared, such as &amp;quot;int&amp;quot; or &amp;quot;string&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Primitive Data Types==&lt;br /&gt;
Primitives are the simplest type of data. Primitives consist of numbers, letters and strings of letters. The following table shows all the types of primitives.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
{| border=1 cellspacing=0 cellpadding=5&lt;br /&gt;
| &#039;&#039;&#039;Primitive&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Description&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Values&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| byte&lt;br /&gt;
| A brief, 8-bit integer&lt;br /&gt;
| Whole numbers -128 through 127&lt;br /&gt;
|-&lt;br /&gt;
| short&lt;br /&gt;
| A short, 16-bit integer&lt;br /&gt;
| Whole numbers -32,768 through 32,767&lt;br /&gt;
|-&lt;br /&gt;
| int&lt;br /&gt;
| A 32 bit integer&lt;br /&gt;
| Whole numbers -2,147,483,648 through 2,147,483,647&lt;br /&gt;
|-&lt;br /&gt;
| long&lt;br /&gt;
| A long, 64 bit integer&lt;br /&gt;
| Whole numbers -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807&lt;br /&gt;
|-&lt;br /&gt;
| float&lt;br /&gt;
| Single-precision floating point (32-bit IEEE 754)&lt;br /&gt;
| Smallest positive non-zero: 14e&amp;lt;sup&amp;gt;-45&amp;lt;/sup&amp;gt;, Largest positive non-zero: 3.4028234e&amp;lt;sup&amp;gt;38&amp;lt;/sup&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| double&lt;br /&gt;
| Double-precision floating point (64-bit IEEE 754)&lt;br /&gt;
| Smallest positive non-zero: 4.9e&amp;lt;sup&amp;gt;-324&amp;lt;/sup&amp;gt;, Largest positive non-zero: 1.797693157e&amp;lt;sup&amp;gt;308&amp;lt;/sup&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| char&lt;br /&gt;
| A single character&lt;br /&gt;
| All Unicode characters&lt;br /&gt;
|-&lt;br /&gt;
| boolean&lt;br /&gt;
| A Boolean value&lt;br /&gt;
| &#039;&#039;&#039;true&#039;&#039;&#039; or &#039;&#039;&#039;false&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declaring Variables==&lt;br /&gt;
In a nutshell, declaring a variable has this syntax:&lt;br /&gt;
&amp;lt;pre&amp;gt; [variable type] [identifier];&amp;lt;/pre&amp;gt;&lt;br /&gt;
This works for both reference variables and primitive variables. [variable type] is the type of variable, like &#039;&#039;&#039;int&#039;&#039;&#039; or &#039;&#039;&#039;char&#039;&#039;&#039;. [identifier] is the name for the variable you wish to create, for example, &#039;&#039;password&#039;&#039; or &#039;&#039;number_of_fish&#039;&#039;. If you wanted to create a &#039;&#039;&#039;int&#039;&#039;&#039; variable called &#039;&#039;age&#039;&#039;, you would type this:&lt;br /&gt;
&amp;lt;pre&amp;gt;int age;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the semicolon at the end of the statement. All statements in Java must end in this, otherwise you will get a compiler error. &lt;br /&gt;
&lt;br /&gt;
You can set the values of variables while declaring them, like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;int age = 100;&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can declare multiple variables on one line, if you wish:&lt;br /&gt;
&amp;lt;pre&amp;gt; boolean a, b;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Also, you can change variables after you already give them a value.&lt;br /&gt;
&amp;lt;pre&amp;gt;[v you want to change] = [v you want it to be]&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Identifiers===&lt;br /&gt;
There are several rules for the naming of your variables. Identifiers can be named using all the letters from A through Z (capital or lowercase, you choose), numbers 0-9 and underscore _ and the dollar sign $. The first character of the identifier cannot be a number, but it can be a letter, _ or $. &lt;br /&gt;
&lt;br /&gt;
You can&#039;t create two variables with the same identifier, all identifiers must be unique. You also can&#039;t use an identifier that is a Java keyword. Here is a list of all the [http://en.wikipedia.org/wiki/Java_keywords Java Keywords].  [[Flashcards for Java keywords]] provides some assistance in memorizing the concepts behind specific keywords.&lt;br /&gt;
&lt;br /&gt;
==Statements==&lt;br /&gt;
A statement in Java is a chunk of code that does something specific completely. Statements are ended by a semicolon ;. An example of a statement is the declaration of a variable like we saw before. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;private int static numberOfObjectsInstantiated;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above declares a single memory location per class which may be incremented each time an object of that class is instantiated by calling its constructor method.&lt;br /&gt;
&lt;br /&gt;
Another example you will recall from the &amp;quot;Hello World&amp;quot; program we made in Lesson 1. &lt;br /&gt;
&amp;lt;pre&amp;gt;System.out.println(&amp;quot;Hello World&amp;quot;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
This line of code prints &#039;&#039;Hello World&#039;&#039; onto the console.&lt;br /&gt;
&lt;br /&gt;
A third example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;if (ourShip.speed&amp;lt;10) then ourShip.mainThrustPulse(2);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above checks a ship object&#039;s speed and if it is less than ten then it commands the ship object to fire two pulses from its main propulsion rockets.  It is a single specific application task completed at the semi-colon when it moves to the next chunk of code.&lt;br /&gt;
&lt;br /&gt;
==Comments==&lt;br /&gt;
Comments are notes that the developer can insert into their code. This allows the developer to keep track of their code and helps when developers are collaborating on a project. It is good to write a summary of the following code at the beginning of your methods, classes, etc. The Java compiler completely ignores comments, so you can say anything in them&lt;br /&gt;
&lt;br /&gt;
Comments are written using two forward slashes&lt;br /&gt;
&amp;lt;pre&amp;gt;//This is a comment&amp;lt;/pre&amp;gt;&lt;br /&gt;
Comments can be written at the end of a line&lt;br /&gt;
&amp;lt;pre&amp;gt;System.out.println(&amp;quot;I love comments&amp;quot;); //This is also a comment&amp;lt;/pre&amp;gt;&lt;br /&gt;
Comments can also be written on multiple lines by starting with &#039;&#039;&#039;/*&#039;&#039;&#039; and ending with&#039;&#039;&#039;*/&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;/* Comment 1&lt;br /&gt;
Comment 2&lt;br /&gt;
Comment 3 */&amp;lt;/pre&amp;gt;&lt;br /&gt;
:Sun recommends the above form be reserved for information intended for automatic JavaDoc documentation.&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
===Assignment Operator = ===&lt;br /&gt;
The assignment operator sets the variable on its left equal to the value on its right. This code creates the variable &#039;&#039;a&#039;&#039; and sets it equal to 5&lt;br /&gt;
&amp;lt;pre&amp;gt;int a;&lt;br /&gt;
a = 5;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Fairly simple, right? Here is where it can get a little more tricky. &lt;br /&gt;
&amp;lt;pre&amp;gt;int a;&lt;br /&gt;
int b;&lt;br /&gt;
b = 6;&lt;br /&gt;
a = b; //a equals 6&amp;lt;/pre&amp;gt;&lt;br /&gt;
At first glance, you might think that the last statement is setting &#039;&#039;a&#039;&#039; equal to the letter &amp;quot;b&amp;quot;, but instead it is setting &#039;&#039;a&#039;&#039; equal to the &#039;&#039;value&#039;&#039; of &#039;&#039;b&#039;&#039;, which is 6.&lt;br /&gt;
&lt;br /&gt;
===Addition Operator +===&lt;br /&gt;
Unlike the = operator, a statement that simply uses the addition operator and two other values on either side does not do anything significant. For example, neither of the following three lines of code do anything.&lt;br /&gt;
&amp;lt;pre&amp;gt;5 + 6;&lt;br /&gt;
a + 9;&lt;br /&gt;
a + b;&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you want to you want to use the addition operator to add 6 to the value of &#039;&#039;a&#039;&#039;, it would be used like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;a = a + 6;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or you can use a shortcut in order to reach the same result as the above.&lt;br /&gt;
&amp;lt;pre&amp;gt;a += 6;&amp;lt;/pre&amp;gt;&lt;br /&gt;
There are shortcuts to all of the operators, which will be shown in the following sections.&lt;br /&gt;
&lt;br /&gt;
===Subtraction -, Division / and Multiplication * Operators===&lt;br /&gt;
&lt;br /&gt;
Just like the addition operator, the Subtraction, Division, and Multiplication operators are used as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int a;&lt;br /&gt;
&lt;br /&gt;
a = a-1;&lt;br /&gt;
a = a/1;&lt;br /&gt;
a = a*1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of &amp;quot;a&amp;quot; in each example would be simply&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1st a - &amp;quot;a&amp;quot; minus 1&lt;br /&gt;
2nd a - &amp;quot;a&amp;quot; divided by 1&lt;br /&gt;
3rd a - &amp;quot;a&amp;quot; multiplied by 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When all of the operators are used at once, for example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int a, b, c, d;&lt;br /&gt;
&lt;br /&gt;
a = a-b/c*d;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You would then use the order or operations, otherwise known as [http://en.wikipedia.org/wiki/PEMDAS PEMDAS], to find the result of &amp;quot;a&amp;quot;; which would be:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a = a - (b/c)d&lt;br /&gt;
or&lt;br /&gt;
         b&lt;br /&gt;
a = a - ---&lt;br /&gt;
       (c*d)&lt;br /&gt;
&lt;br /&gt;
(either way the result is the same)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or if you prefer actual numbers, it would look like so:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int a = 1;&lt;br /&gt;
int b = 2;&lt;br /&gt;
int c = 2;&lt;br /&gt;
int d = 1;&lt;br /&gt;
&lt;br /&gt;
a = 1-2/2*1;&lt;br /&gt;
&lt;br /&gt;
thus:&lt;br /&gt;
&lt;br /&gt;
a = 1 - 1&lt;br /&gt;
or &lt;br /&gt;
a = 0;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;More coming soon&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[Topic:Java|Back to Java Main Page]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>70.255.198.170</name></author>
	</entry>
	<entry>
		<id>https://ideawaza.com/index.php?title=Basic_Java_Language&amp;diff=36717</id>
		<title>Basic Java Language</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=Basic_Java_Language&amp;diff=36717"/>
		<updated>2006-11-26T02:52:18Z</updated>

		<summary type="html">&lt;p&gt;70.255.198.170: /* Addition Operator + */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This lesson discusses the basics of the Java language, including variables, primitives, operators, statements and Java writing conventions.&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are used to store data that can change. There are two main categories of variables, &#039;&#039;reference variables&#039;&#039; and &#039;&#039;primitive variables&#039;&#039;. Reference variables are place holders for objects (More on objects in Lesson 4, [[Java Objects and Classes]].) Primitive variables are given a value of a primitive, a basic value. Variables are all given a type when they are declared, such as &amp;quot;int&amp;quot; or &amp;quot;string&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Primitive Data Types==&lt;br /&gt;
Primitives are the simplest type of data. Primitives consist of numbers, letters and strings of letters. The following table shows all the types of primitives.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
{| border=1 cellspacing=0 cellpadding=5&lt;br /&gt;
| &#039;&#039;&#039;Primitive&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Description&#039;&#039;&#039;&lt;br /&gt;
| &#039;&#039;&#039;Values&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| byte&lt;br /&gt;
| A brief, 8-bit integer&lt;br /&gt;
| Whole numbers -128 through 127&lt;br /&gt;
|-&lt;br /&gt;
| short&lt;br /&gt;
| A short, 16-bit integer&lt;br /&gt;
| Whole numbers -32,768 through 32,767&lt;br /&gt;
|-&lt;br /&gt;
| int&lt;br /&gt;
| A 32 bit integer&lt;br /&gt;
| Whole numbers -2,147,483,648 through 2,147,483,647&lt;br /&gt;
|-&lt;br /&gt;
| long&lt;br /&gt;
| A long, 64 bit integer&lt;br /&gt;
| Whole numbers -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807&lt;br /&gt;
|-&lt;br /&gt;
| float&lt;br /&gt;
| Single-precision floating point (32-bit IEEE 754)&lt;br /&gt;
| Smallest positive non-zero: 14e&amp;lt;sup&amp;gt;-45&amp;lt;/sup&amp;gt;, Largest positive non-zero: 3.4028234e&amp;lt;sup&amp;gt;38&amp;lt;/sup&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| double&lt;br /&gt;
| Double-precision floating point (64-bit IEEE 754)&lt;br /&gt;
| Smallest positive non-zero: 4.9e&amp;lt;sup&amp;gt;-324&amp;lt;/sup&amp;gt;, Largest positive non-zero: 1.797693157e&amp;lt;sup&amp;gt;308&amp;lt;/sup&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| char&lt;br /&gt;
| A single character&lt;br /&gt;
| All Unicode characters&lt;br /&gt;
|-&lt;br /&gt;
| boolean&lt;br /&gt;
| A Boolean value&lt;br /&gt;
| &#039;&#039;&#039;true&#039;&#039;&#039; or &#039;&#039;&#039;false&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declaring Variables==&lt;br /&gt;
In a nutshell, declaring a variable has this syntax:&lt;br /&gt;
&amp;lt;pre&amp;gt; [variable type] [identifier];&amp;lt;/pre&amp;gt;&lt;br /&gt;
This works for both reference variables and primitive variables. [variable type] is the type of variable, like &#039;&#039;&#039;int&#039;&#039;&#039; or &#039;&#039;&#039;char&#039;&#039;&#039;. [identifier] is the name for the variable you wish to create, for example, &#039;&#039;password&#039;&#039; or &#039;&#039;number_of_fish&#039;&#039;. If you wanted to create a &#039;&#039;&#039;int&#039;&#039;&#039; variable called &#039;&#039;age&#039;&#039;, you would type this:&lt;br /&gt;
&amp;lt;pre&amp;gt;int age;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the semicolon at the end of the statement. All statements in Java must end in this, otherwise you will get a compiler error. &lt;br /&gt;
&lt;br /&gt;
You can set the values of variables while declaring them, like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;int age = 100;&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can declare multiple variables on one line, if you wish:&lt;br /&gt;
&amp;lt;pre&amp;gt; boolean a, b;&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Identifiers===&lt;br /&gt;
There are several rules for the naming of your variables. Identifiers can be named using all the letters from A through Z (capital or lowercase, you choose), numbers 0-9 and underscore _ and the dollar sign $. The first character of the identifier cannot be a number, but it can be a letter, _ or $. &lt;br /&gt;
&lt;br /&gt;
You can&#039;t create two variables with the same identifier, all identifiers must be unique. You also can&#039;t use an identifier that is a Java keyword. Here is a list of all the [http://en.wikipedia.org/wiki/Java_keywords Java Keywords].  [[Flashcards for Java keywords]] provides some assistance in memorizing the concepts behind specific keywords.&lt;br /&gt;
&lt;br /&gt;
==Statements==&lt;br /&gt;
A statement in Java is a chunk of code that does something specific completely. Statements are ended by a semicolon ;. An example of a statement is the declaration of a variable like we saw before. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;private int static numberOfObjectsInstantiated;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above declares a single memory location per class which may be incremented each time an object of that class is instantiated by calling its constructor method.&lt;br /&gt;
&lt;br /&gt;
Another example you will recall from the &amp;quot;Hello World&amp;quot; program we made in Lesson 1. &lt;br /&gt;
&amp;lt;pre&amp;gt;System.out.println(&amp;quot;Hello World&amp;quot;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
This line of code prints &#039;&#039;Hello World&#039;&#039; onto the console.&lt;br /&gt;
&lt;br /&gt;
A third example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;if (ourShip.speed&amp;lt;10) then ourShip.mainThrustPulse(2);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above checks a ship object&#039;s speed and if it is less than ten then it commands the ship object to fire two pulses from its main propulsion rockets.  It is a single specific application task completed at the semi-colon when it moves to the next chunk of code.&lt;br /&gt;
&lt;br /&gt;
==Comments==&lt;br /&gt;
Comments are notes that the developer can insert into their code. This allows the developer to keep track of their code and helps when developers are collaborating on a project. It is good to write a summary of the following code at the beginning of your methods, classes, etc. The Java compiler completely ignores comments, so you can say anything in them&lt;br /&gt;
&lt;br /&gt;
Comments are written using two forward slashes&lt;br /&gt;
&amp;lt;pre&amp;gt;//This is a comment&amp;lt;/pre&amp;gt;&lt;br /&gt;
Comments can be written at the end of a line&lt;br /&gt;
&amp;lt;pre&amp;gt;System.out.println(&amp;quot;I love comments&amp;quot;); //This is also a comment&amp;lt;/pre&amp;gt;&lt;br /&gt;
Comments can also be written on multiple lines by starting with &#039;&#039;&#039;/*&#039;&#039;&#039; and ending with&#039;&#039;&#039;*/&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;/* Comment 1&lt;br /&gt;
Comment 2&lt;br /&gt;
Comment 3 */&amp;lt;/pre&amp;gt;&lt;br /&gt;
:Sun recommends the above form be reserved for information intended for automatic JavaDoc documentation.&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
===Assignment Operator = ===&lt;br /&gt;
The assignment operator sets the variable on its left equal to the value on its right. This code creates the variable &#039;&#039;a&#039;&#039; and sets it equal to 5&lt;br /&gt;
&amp;lt;pre&amp;gt;int a;&lt;br /&gt;
a = 5;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Fairly simple, right? Here is where it can get a little more tricky. &lt;br /&gt;
&amp;lt;pre&amp;gt;int a;&lt;br /&gt;
int b;&lt;br /&gt;
b = 6;&lt;br /&gt;
a = b; //a equals 6&amp;lt;/pre&amp;gt;&lt;br /&gt;
At first glance, you might think that the last statement is setting &#039;&#039;a&#039;&#039; equal to the letter &amp;quot;b&amp;quot;, but instead it is setting &#039;&#039;a&#039;&#039; equal to the &#039;&#039;value&#039;&#039; of &#039;&#039;b&#039;&#039;, which is 6.&lt;br /&gt;
&lt;br /&gt;
===Addition Operator +===&lt;br /&gt;
Unlike the = operator, a statement that simply uses the addition operator and two other values on either side does not do anything significant. For example, neither of the following three lines of code do anything.&lt;br /&gt;
&amp;lt;pre&amp;gt;5 + 6;&lt;br /&gt;
a + 9;&lt;br /&gt;
a + b;&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you want to you want to use the addition operator to add 6 to the value of &#039;&#039;a&#039;&#039;, it would be used like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;a = a + 6;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or you can use a shortcut in order to reach the same result as the above.&lt;br /&gt;
&amp;lt;pre&amp;gt;a += 6;&amp;lt;/pre&amp;gt;&lt;br /&gt;
There are shortcuts to all of the operators, which will be shown in the following sections.&lt;br /&gt;
&lt;br /&gt;
===Subtraction -, Division / and Multiplication * Operators===&lt;br /&gt;
&lt;br /&gt;
Just like the addition operator, the Subtraction, Division, and Multiplication operators are used as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int a;&lt;br /&gt;
&lt;br /&gt;
a = a-1;&lt;br /&gt;
a = a/1;&lt;br /&gt;
a = a*1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of &amp;quot;a&amp;quot; in each example would be simply&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1st a - &amp;quot;a&amp;quot; minus 1&lt;br /&gt;
2nd a - &amp;quot;a&amp;quot; divided by 1&lt;br /&gt;
3rd a - &amp;quot;a&amp;quot; multiplied by 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When all of the operators are used at once, for example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int a, b, c, d;&lt;br /&gt;
&lt;br /&gt;
a = a-b/c*d;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You would then use the order or operations, otherwise known as [http://en.wikipedia.org/wiki/PEMDAS PEMDAS], to find the result of &amp;quot;a&amp;quot;; which would be:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a = a - (b/c)d&lt;br /&gt;
or&lt;br /&gt;
         b&lt;br /&gt;
a = a - ---&lt;br /&gt;
       (c*d)&lt;br /&gt;
&lt;br /&gt;
(either way the result is the same)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or if you prefer actual numbers, it would look like so:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int a = 1;&lt;br /&gt;
int b = 2;&lt;br /&gt;
int c = 2;&lt;br /&gt;
int d = 1;&lt;br /&gt;
&lt;br /&gt;
a = 1-2/2*1;&lt;br /&gt;
&lt;br /&gt;
thus:&lt;br /&gt;
&lt;br /&gt;
a = 1 - 1&lt;br /&gt;
or &lt;br /&gt;
a = 0;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;More coming soon&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[Topic:Java|Back to Java Main Page]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>70.255.198.170</name></author>
	</entry>
</feed>