mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +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
c7240369b6
commit
63793af2e9
@ -47,10 +47,30 @@ public class LearnJava {
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// Types & Variables
|
// Variables
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Variable Declaration
|
||||||
|
*/
|
||||||
// Declare a variable using <type> <name>
|
// 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
|
// Byte - 8-bit signed two's complement integer
|
||||||
// (-128 <= byte <= 127)
|
// (-128 <= byte <= 127)
|
||||||
byte fooByte = 100;
|
byte fooByte = 100;
|
||||||
|
@ -101,9 +101,7 @@ $sgl_quotes
|
|||||||
END;
|
END;
|
||||||
|
|
||||||
// String concatenation is done with .
|
// String concatenation is done with .
|
||||||
echo 'This string ' . 'is concatenated';
|
echo 'This string ' . 'is concatenated';
|
||||||
// Strings concatenation can also be combined with html elements
|
|
||||||
echo 'This string is' . '<strong>' . 'bold with strong tags ' . '</strong>.'
|
|
||||||
|
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
|
Loading…
Reference in New Issue
Block a user