summaryrefslogtreecommitdiffhomepage
path: root/java.html.markdown
diff options
context:
space:
mode:
authorDhwani Shah <dshah202@gmail.com>2015-10-02 14:54:09 -0500
committerDhwani Shah <dshah202@gmail.com>2015-10-02 14:54:09 -0500
commit63793af2e955f8a8abe698c4a70809cfbff63452 (patch)
treeaf03b4c7feedd98b806456263835452bf86ac49f /java.html.markdown
parentc7240369b6465f2a736cb61d1bff89c971e76929 (diff)
Added section on how to declare and initialize both single varible and multiple varibles with the same value. Important concept for large structured programs. Seperated this a little bit.
Diffstat (limited to 'java.html.markdown')
-rw-r--r--java.html.markdown24
1 files changed, 22 insertions, 2 deletions
diff --git a/java.html.markdown b/java.html.markdown
index 928eb39f..1aa06570 100644
--- a/java.html.markdown
+++ b/java.html.markdown
@@ -47,10 +47,30 @@ public class LearnJava {
///////////////////////////////////////
- // Types & Variables
+ // Variables
///////////////////////////////////////
-
+
+ /*
+ * Variable Declaration
+ */
// Declare a variable using <type> <name>
+ int fooInt;
+ // Declare multiple variables of the same type <type> <name1>, <name2>, <name3>
+ int fooInt1, fooInt2, fooInt3;
+
+ /*
+ * Variable Initialization
+ */
+
+ // Initialize a variable using <type> <name> = <val>
+ int fooInt = 1;
+ // Initialize multiple variables of same type with same value <type> <name1>, <name2>, <name3> = <val>
+ int fooInt1, fooInt2, fooInt3;
+ fooInt1 = fooInt2 = fooInt3 = 1;
+
+ /*
+ * Variable types
+ */
// Byte - 8-bit signed two's complement integer
// (-128 <= byte <= 127)
byte fooByte = 100;