Java             3GL - .   4GL -     DB-

JAVA

Java

(package) , , . , List, , - List.

 

, , . . . , .

 

, , (name space). , , . , , . .java 4 , . Java.

package ()

import ()

(public)

(private) ()

 

package

, Java package, , . , . package , , . , , ,

package java.awt.image;

java/awt/image.

 

, Java , , LASSPATH. ( ; PATH).

 

, . , , . , .

, PackTest test. test, PackTest.Java . . can't find class PackTest (He PackTest). test, , - test.PackTest. java test.PackTest, CLASSPATH , .

 

import

package, Java-, import. , Java . import :

import 1 [.2].(|*);

1 , 2 , . , , , , . , , Java- - , , . import :

import java.util.Date

import java.io.*;

 

import , .. ( ).

 

Java , , java. java.lang. .

import java.lang.*;

, import , , , . , , import, , .

class MyDate extends Java.util.Date { }

 

Java , . - Java :

.

.

.

, .

 

Java , : private (), public () protected (), . () ().

 

 

private

private protected

protected

public

 

, , . , public, . , private, , . , . Java . , , , , protected. , , , , private protected.

 

, . : Protection, Derived SamePackage. . n , n_pri private, n_pro protected, n_pripro private protected n_pub public. . , - , (//) , . Derived Protection 1. n_pri. , SamePackage, , Protection. n_pri, n_pripro, private protected.

 

package 1;

public class Protection {

int n = 1;

private int n_pri = 2;

protected int n_pro = 3;

private protected int n_pripro = 4;

public int n_pub = 5;

public Protection() {

System.out.println("base constructor");

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

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

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

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

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

} }

class Derived extends Protection {

Derived() {

          System.out.println("derived constructor");

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

          //

          // System.out.println("n_pri = " + n_pri);

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

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

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

} }

class  SamePackage {

SamePackage() {

              Protection p = new Protection();

              System.out.println("same package constructor");

              System.out.println("n = " + p.n);

              //

              // System.out.println("n_pri = " + p.n_pri);

              System.out.println("n_pro = " + p.n_pro);

              //

              // System.out.println("n_pripro = " + p.n_pripro):

              System.out.println("n_pub = " + p.n_pub):

} }

 

Java (resolution) . , , . . , . . , . , . . C++, .

 

interface

, , . :

interface {

_ _1( );

_final1- = ;

}

. ; ( ). , final - . , . , . , callback int.

interface Callback {

void callback(int param);

}

 

implements

implements , ().

class _ [extends ]

[implements 0 [, 1...]] { }

, . , :

 

class Client implements Callback {

void callback(int p) {

System.out.println("callback called with " + p);

} }

 

callback , , - :

 

class TestIface {

public static void main(String args[]) { Callback = new client();

c.callback(42);

} }

 

:

:\> Java TestIface

callback called with 42

 

. , - , . - C++ #define const Pascal / Delphi.

 

, , , . final. .

 

import java.util.Random;

interface SharedConstants { int NO = 0;

int YES = 1;

int MAYBE = 2;

int LATER = 3;

int SOON = 4;

int NEVER = 5; }

class Question implements SharedConstants {

Random rand = new Random();

int ask() {

int prob = (int) (100 * rand.nextDouble());

if (prob < 30)

return NO; // 30% else if (prob < 60)

return YES; // 30% else if (prob < 75)

return LATER; // 15% else if (prob < 98)

return SOON; // 13% else

return NEVER; // 2% } }

class AskMe implements SharedConstants {

static void answer(int result) {

switch(result) {

case NO:

System.out.println("No");

break;

case YES:

       System.out.println("Yes");

       break;

case MAYBE:

       System.out.println("Maybe");

       break;

case LATER:

       System.out.println("Later");

       break;

case SOON:

       System.out.priniln("Soon");

       break;

case NEVER:

       System.out.println("Never");

       break;

} }

public static void main(String args[]) {  

Question q = new Question();

       answer(q.ask());

       answer(q.ask());

       answer(q.askO);

       answer(q.ask());

} }

 

, , Random java.util. 12.

 

:\> Java AskMe

Later

Scon

No

Yes

 

. . , , , - . Java, java.lang. , .

 

Java             3GL - .   4GL -     DB-


, - , . , , , .. , . . , " ".




 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