<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.omnivision.website/index.php?action=history&amp;feed=atom&amp;title=3.2.3_Variable_Declaration_and_Initialization</id>
	<title>3.2.3 Variable Declaration and Initialization - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.omnivision.website/index.php?action=history&amp;feed=atom&amp;title=3.2.3_Variable_Declaration_and_Initialization"/>
	<link rel="alternate" type="text/html" href="https://wiki.omnivision.website/index.php?title=3.2.3_Variable_Declaration_and_Initialization&amp;action=history"/>
	<updated>2026-05-23T00:22:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.omnivision.website/index.php?title=3.2.3_Variable_Declaration_and_Initialization&amp;diff=107&amp;oldid=prev</id>
		<title>Mr. Goldstein: Created page with &quot;=== 3.2.3 Variable Declaration and Initialization === Imagine you&#039;re setting up those labeled boxes for your information. Before you can put anything &#039;&#039;into&#039;&#039; a box, you first need to:  # &#039;&#039;&#039;Declare&#039;&#039;&#039; the box (give it a name and say what kind of stuff will go in it). # &#039;&#039;&#039;Initialize&#039;&#039;&#039; the box (put a starting piece of information in it).  &#039;&#039;&#039;Variable Declaration&#039;&#039;&#039;  * This is where you tell the computer: &quot;Hey, I&#039;m going to need a storage spot, and here&#039;s what I&#039;m going...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.omnivision.website/index.php?title=3.2.3_Variable_Declaration_and_Initialization&amp;diff=107&amp;oldid=prev"/>
		<updated>2025-07-07T19:39:45Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=== 3.2.3 Variable Declaration and Initialization === Imagine you&amp;#039;re setting up those labeled boxes for your information. Before you can put anything &amp;#039;&amp;#039;into&amp;#039;&amp;#039; a box, you first need to:  # &amp;#039;&amp;#039;&amp;#039;Declare&amp;#039;&amp;#039;&amp;#039; the box (give it a name and say what kind of stuff will go in it). # &amp;#039;&amp;#039;&amp;#039;Initialize&amp;#039;&amp;#039;&amp;#039; the box (put a starting piece of information in it).  &amp;#039;&amp;#039;&amp;#039;Variable Declaration&amp;#039;&amp;#039;&amp;#039;  * This is where you tell the computer: &amp;quot;Hey, I&amp;#039;m going to need a storage spot, and here&amp;#039;s what I&amp;#039;m going...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== 3.2.3 Variable Declaration and Initialization ===&lt;br /&gt;
Imagine you&amp;#039;re setting up those labeled boxes for your information. Before you can put anything &amp;#039;&amp;#039;into&amp;#039;&amp;#039; a box, you first need to:&lt;br /&gt;
&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Declare&amp;#039;&amp;#039;&amp;#039; the box (give it a name and say what kind of stuff will go in it).&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Initialize&amp;#039;&amp;#039;&amp;#039; the box (put a starting piece of information in it).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Variable Declaration&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* This is where you tell the computer: &amp;quot;Hey, I&amp;#039;m going to need a storage spot, and here&amp;#039;s what I&amp;#039;m going to call it, and what kind of data it will hold.&amp;quot;&lt;br /&gt;
* You typically specify the &amp;#039;&amp;#039;&amp;#039;data type&amp;#039;&amp;#039;&amp;#039; first, then the &amp;#039;&amp;#039;&amp;#039;variable name&amp;#039;&amp;#039;&amp;#039;.  &amp;#039;&amp;#039;&amp;#039;Example (in plain English):&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
** &amp;lt;code&amp;gt;Number called age&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;Text called username&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;True/False called is_active&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Variable Initialization&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* This is where you give the variable its very first value. It&amp;#039;s like putting the first item into your labeled box.&lt;br /&gt;
* You do this using the &amp;#039;&amp;#039;&amp;#039;assignment operator&amp;#039;&amp;#039;&amp;#039;, which is usually an equals sign (&amp;lt;code&amp;gt;=&amp;lt;/code&amp;gt;).  &amp;#039;&amp;#039;&amp;#039;Example (in plain English):&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
** &amp;lt;code&amp;gt;age = 12&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;username = &amp;quot;CoderKid&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;is_active = true&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Putting it Together (Declaration and Initialization):&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
You can declare a variable and initialize it on the same line, which is very common:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;For Primitive Data Types:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
** &amp;lt;code&amp;gt;int score = 0;&amp;lt;/code&amp;gt; (A whole number variable named &amp;lt;code&amp;gt;score&amp;lt;/code&amp;gt; starts at 0)&lt;br /&gt;
** &amp;lt;code&amp;gt;double pi = 3.14;&amp;lt;/code&amp;gt; (A decimal number variable named &amp;lt;code&amp;gt;pi&amp;lt;/code&amp;gt; starts at 3.14)&lt;br /&gt;
** &amp;lt;code&amp;gt;boolean game_over = false;&amp;lt;/code&amp;gt; (A true/false variable named &amp;lt;code&amp;gt;game_over&amp;lt;/code&amp;gt; starts as false)&lt;br /&gt;
** &amp;lt;code&amp;gt;char first_initial = &amp;#039;J&amp;#039;;&amp;lt;/code&amp;gt; (A character variable named &amp;lt;code&amp;gt;first_initial&amp;lt;/code&amp;gt; starts as &amp;#039;J&amp;#039;)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;For Reference Data Types (like Strings and Objects):&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
** &amp;lt;code&amp;gt;String greeting = &amp;quot;Hello!&amp;quot;;&amp;lt;/code&amp;gt; (A text variable named &amp;lt;code&amp;gt;greeting&amp;lt;/code&amp;gt; stores &amp;quot;Hello!&amp;quot;)&lt;br /&gt;
** &amp;lt;code&amp;gt;Car myCar = new Car();&amp;lt;/code&amp;gt; (An object variable named &amp;lt;code&amp;gt;myCar&amp;lt;/code&amp;gt; now points to a brand new &amp;lt;code&amp;gt;Car&amp;lt;/code&amp;gt; object)  &amp;#039;&amp;#039;Important Note for Reference Types:&amp;#039;&amp;#039; When you declare a reference variable but don&amp;#039;t initialize it (e.g., &amp;lt;code&amp;gt;String message;&amp;lt;/code&amp;gt;), it usually starts with a special value called &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; means &amp;quot;no object is being pointed to right now.&amp;quot; If you try to use a &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; variable to do something, your program will likely crash!&lt;br /&gt;
&lt;br /&gt;
Understanding how to declare and initialize variables is the first step to making your programs store and work with information effectively.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Bibliography:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;GeeksforGeeks - Variables in Java&amp;#039;&amp;#039;&amp;#039;: https://www.geeksforgeeks.org/variables-in-java/&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;W3Schools - JavaScript Variables&amp;#039;&amp;#039;&amp;#039;: https://www.w3schools.com/js/js_variables.asp (Good for general concept, even if JavaScript specific)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Wikipedia - Variable (computer science)&amp;#039;&amp;#039;&amp;#039;: https://en.wikipedia.org/wiki/Variable_(computer_science)&lt;/div&gt;</summary>
		<author><name>Mr. Goldstein</name></author>
	</entry>
</feed>