Java             3GL - .   4GL -     DB-

JAVA

Java

Java , , . , . , , . , . , .

 

Java 44 . 4 - , ,   .

 

(. ). . , , char , Java char int.

+

+ =

-

( )

-=

*

* =

/

/=

%

%=

++

--

 

, , , . , , .

 

class BasicMath  { public static void int a = 1 + 1;

int  b = a *  3;

main(String args[]) {

int c = b / 4;

int d = b - ;

int e = -d;

System.out.println("a =  " +    );

System.out.println("b =  " +    b);

System.out.println("c =  " +    c);

System.out.println("d =  " +    d);

System.out.println("e =  " +    e);

} }

 

, :

C: \> java BasicMath

a = 2

b = 6

c = 1

d = 4

e = -4

 

, mod, %. . C++, mod Java , . .

 

class Modulus {

public static void main (String args []) {

int x = 42;

double = 42.3;

System.out.println("x mod 10 = " + x % 10);

System.out.println("y mod 10 = " + % 10);

} }

 

, :

:\> Modulus

x mod 10 = 2

y mod 10 = 2.3

 

, . , .

 

class OpEquals {

public static void main(String args[]) {

int a = 1;

int b = 2;

int = 3;

a += 5;

b *= 4;

c += a * b;

%= 6;

System.out.println("a = " + a);

System.out.println("b = " + b);

System.out.println("c = " + c);

} }

 

, :

:> Java OpEquals

= 6

b = 8

= 3

 

2 , (++ --) . , , . .

 

class IncDec {

public static void main(String args[]) {

int a = 1;

int b = 2;

int c = ++b;

int d = a++;

c++;

System.out.println("a = " + a);

System.out.println("b = " + b);

System.out.println("c = " + c);

System.out.println("d = " + d);

} }

 

:

C:\ java IncDec

a = 2

b = 3

c = 4

d = 1

 

long, int, short, char byte, , . . .

~

(NOT)

 

 

 

 

&

(AND)

&=

(AND)

|

(OR)

|=

(OR)

^

(XOR)

^=

(XOR)

>>

>> =

>>>

>>>=

<<

<<=

 

,

, , , . Java.

OR

AND

XOR

NOT A

0

0

0

0

0

1

1

0

1

0

1

0

0

1

1

0

1

1

1

1

1

1

0

0

 

class Bitlogic {

public static void main(String args []) {

String binary[] = { "OOOO", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001",      "1010", "1011", "1100", "1101",

"1110", "1111" };

int a = 3;   //     0+2+1  0011

int b = 6;   //     4+2+0  0110

int c = a | b;

int d = a & b;

int e = a ^ b;

int f = (~a & b) | (a & ~b);

int g = ~a & 0x0f;

System.out.println(" a = " + binary[a]);

System.out.println(" b = " + binary[b]);

System.out.println(" ab = " + binary[c]);

System.out.println(" a&b = " + binary[d]);

System.out.println(" a^b = " + binary[e]);

System.out.rintln("~a&b|^~ = " + binary[f]);

System.out.println(" ~a = " + binary[g]);

} }

 

, :

: \> Java BitLogic

a = 0011

b = 0110

a | b = 0111

a & b = 0010

a ^ b = 0101

~a & b | a & ~b = 0101

~ = 1100

 

<< , . , . int int . long, long.

 

>> Java . , . , . () . .

 

, . - , 00f, , , .

 

class  HexByte {

static public void main(String args[]) {

char hex[] = { '0', '1, '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f };

byte b = (byte) 0xf1;

System.out.println(b = 0x + hex[(b >> 4) & 0x0f] +   hex[b & 0x0f]);

} }

 

:

:\> java HexByte

b = 0xf1

 

, , .

 

class ByteUShift   {

static public void main(String args[]) {

char hex[] = { '0', '1, '2', '3', '4',    '5', '6', '7', '8', '9', '', 'b', '', 'd',       'e', 'f };

byte b = (byte) 0xf1;

byte c = (byte) (b >> 4);

byte d = (byte) (b >> 4);

byte e = (byte) ((b & 0xff) >> 4);

System.out.println(" b = 0x" + hex(b >> 4) & 0x0f] + hex[b & 0x0f]);

System.out.println( b >> 4 =  0x" + hex[(c >> 4) & 0x0f] + hex[c & 0x0f]);

System.out.println(b >>> 4 = 0x" + hex[(d >> 4) & 0x0f] + hex[d & 0x0f]);

System.out.println((b & 0xff) >> 4 = 0x" + hex[(e >> 4) & 0x0f] + hex[e & 0x0f]);

} }

 

b , 0xf1. b 4 . , , 0xf1 0xff. d b 4 . , d 0x0f, 0xff. , b int . , 0x0f. b 0xff, , . , , AND.

: \> java ByteUShift

b = 0xf1

b >> 4 = 0xff

b >>> 4 = 0xff

b & 0xff) >> 4 = 0x0f

, , , . , , , .

 

class OpBitEquals {

public static void main(String args[]) {

int a = 1;

int b = 2;

int = 3;

a |= 4;

b >>= 1;

<<= 1;

^= ;

System.out.println("a = " + a);

System.out.println("b = " + b);

System.out.println("c = " + c);

} }

 

:

:\> Java OpBitEquals

= 3

b = 1

= 6

 

, , Java , . .

==

!=

>

<

>=

<=

, , , , , == !=. Java, , C++ (==). (=) .

 

, , boolean. boolean .

&

(AND)

&=

(AND)

|

(OR)

=

(OR)

^

(XOR)

^=

(XOR)

||

OR (short circuit OR)

==

&&

AND (short circuit AND)

!=

!

(NOT)

?:

if-then-else

.

OR

AND

XOR

NOT A

false

false

false

false

false

true

true

false

true

false

true

false

false

true

true

false

true

true

true

true

true

true

false

false

 

, , BitLogic. .

 

class BoolLogic {

public static void main(String args[]) {

boolean a = true;

boolean b = false;

boolean = a | b;

boolean d = a & b;

boolean e = a ^ b;

boolean f = (!a & b) | (a & !b);

boolean g = !a;

System.out.println(" a = " + a);

System.out.println(" b = " + b);

System.out.println(" a|b = " + c);

System.out.println(" a&b = " + d);

System.out.println(" a^b = " + e);

System.out.println("!a&b|a&!b = " + f);

System.out.println(" !a = " + g);

} }

 

: \> Java BoolLogic

= true

b = false

a|b = true

a&b = false

a^b = true

!a&b|a&!b = true

!a = false

 

(short circuit logical operators)

. AND OR, . , OR true, true. AND, false, false. && || & |, Java , .   && || . & | .

 

if-then-else

if-then-use :

1? 2:

1 , boolean. true, , , , 2. pa false, ǻ. , 2 ǻ, void.

 

. 0.

 

class Ternary {

public static void main(String args[]) {

int a = 42;

int b = 2;

int c = 99;

int d = 0;

int e = (b == 0) ? 0 : (a / b);

int f = (d == 0) ? 0 : (c / d);

System.out.println("a = " + a);

System.out.println("b = " + b);

System.out.println("c = " + c);

System.out.println("d = " + d);

System.out.println("a / b = " + e);

System.out.println("c / d = " + f);

} }

 

:

: \>java Ternary

= 42

b = 2

= 99

d = 0

a / b = 21

/ d  = 0

 

Java , , . , , . . Java.

( )

[ ]

.

 

 

 

~

!

 

 

*

/

%

 

+

-

 

 

>>

>>>

<<

 

 

>

>=

<

<=

==

 

!=

 

 

 

 

&

 

 

 

 

 

 

^

 

 

 

 

 

 

|

 

 

 

 

 

 

&&

 

 

 

 

 

 

| |

 

 

 

 

 

 

?:

 

 

 

 

 

 

=

op=

 

 

 

 

, . () . , [] -. . () 7. .

 

, , .

>> b + 3

, >> (b + 3) ( >> b) + 3, ? , , >> (b + ). (>>b)+ 3 .

                                   

?

, Java. . , .

 

Java             3GL - .   4GL -     DB-


, , Class diagram - - , - .




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution