sobota, 18 lipca 2015

Variables, Assignment instruction.

Variables are like 'boxes' that can contain something. Variables can have names, or 'labels'. Variables' size is measured in number of bits or bytes, etc ... Variables, can contain a value, a number, a character, or other data.

One can say that we 'put' a value into 'a variable' as into a box.


Other words to express that physical phenomenon is saying i assign value of '3' to a variable named
(labelled as) 'firstNumber'.



it's assignment instruction, depending on notation (syntax) it can be written as:

  first_number = 3;
  first_number := 3;
  firstNumber = 3;

after assigning a value to a variable, variable contains that value in itself, has that value.



we can assign variable's value to another variable as well.

  secondNumber = firstNumber;

often a variable has to be declared before being used, assigned a type & size, destined to contain certain type of data.

in Java & in many other Programming Languages it's neccessary to declare data type of a variable.

there are other Programming Languages that behave differently.

in Java there's no neccessity to put variable declaration at beginning of a 'method', code's part.

notation (syntax) used in Java is:

  int firstNumber = 3;
  firstNumber = 4;

yes, data type has to be declared only once, for certain code's part.

variable declaration with assignment in one line is called 'definition'.

where 'int' is 'integer data type', it allows for storing numbers from -2147483648 to 2147483647, inclusively.

in Java, integer is 32-bit signed number.

more about 'data types' later.

occassionally, an 'assignment instruction' is called a 'LET instruction'.

Bits, Bytes, Characters.

bit is smallest unit of information, either 0 or 1.

byte is unit of 8 bits, or in more advanced, more modern or future machines it's 16, 32, 64, 128, ...

central processing unit's (processor's) architecture makes it natural to use larger bytes, code is more optimal that way.

more of memory can be used in computer as well, because of adressing memory with more-bit numbers.

8-bit byte allows for storing (representing) in memory 28 = 256 different numbers or other symbols.

8-bit byte allows for storing in memory ASCII-encoded character (letter for example).



ASCII-encoded character table, part of ...


there are also other forms of encoding letters & other characters, proper Unicode for example.

since version 5.2. unicode allows for encoding Vedic Sanskrit characters as well.

Java uses Unicode-encoded characters.

Unicode standard has many substandards, that use different amount of bits for encoding a character.

for example: UTF-1, UTF-7, UTF-8, UTF-EBCDIC, UTF-16, UTF-32.

occasionally two bytes are called: 'word', perhaps there's more of that ...

piątek, 17 lipca 2015

Number Notations.

numbers as well as other data can be presented in many ways.

using {0,1} numbers as well.

most common system used is 'decimal notation', developed probably because of number of fingers.

there are other notations, for example:

- unsigned binary, that uses only two numbers: {0, 1},
- octal, that uses: {0, 1, 2, 3, 4, 5, 6, 7},
- hexadecimal, that uses: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F},
- signed binary (in many forms), that use: {0, 1}.

Decimal Unsigned Binary Octal Hexadecimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10
17 10001 21 11


see also, if You wish: Signed number representations.

(to be elaborated as time & mind state allows)

Introduction.

Motto: '‎forget about being taught and concentrate on learning. when You are sure, question everything.'.
---


Java Programming Language is important part of Programming Ecosystem & Environment that was created mostly by Sun Microsystems, then taken over by Oracle.

Object Oriented Methodologies (Object Oriented Analysis, Object Oriented Design, Object Oriented Programming) are part(s) of Java, should be mentioned & elaborated on this blog, when/if i have time for that.

There are other tools & parts that Professional Companies use, but this is not within the scope of this blog.

This blog should help user learn how to use Java Language, Professionally, in an Object Oriented Way.

For many it's enough to hire someone, i think.

Computer Sciences are broad enough in scope to ensure that no single person will grasp 'the whole', that's why i'll teach a subset of Java Programming Language & a subset of Object Oriented Programming as well.

Enterprise Solutions for Java are there, i'll mention a few in that blog ... when/if i have time.

Best to not waste too much of time on them, however, in my opinion.

There are things i'll mention in other 'places', for example: there.