mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
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.
This commit is contained in:
parent
fb43ef2942
commit
8e388cd334
@ -47,10 +47,30 @@ public class LearnJava {
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// Types & Variables
|
||||
// Variables
|
||||
///////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
* Variable Declaration
|
||||
*/
|
||||
// Declare a variable using <type> <name>
|
||||
int fooInt;
|
||||
// Declare multiple variables of 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;
|
||||
|
Loading…
Reference in New Issue
Block a user