Java             3GL - .   4GL -     DB-

JAVA

Java

, Java. java.lang java.util. , , , .

, Java , , int char . Java. , . Java .

Number

Number : long, int, float double.

, ( ) :

doubleValue() double.

floatValue() float.

intValue() int.

longValue() long.

Double Float

Double Float Number. , , , double float. , double float, , , String, . Double .

class DoubleDemo {
public static void main(String args[]) {
Double d1 = new Double(3.14159);
Double d2 = new Double("314159E-5");
System.out.println(d1 + " = " + d2 + " -> " + d1.equals(d2));
} }

, equals true, , Double.

:\> java DoubleDemo
3.14159 = 3.14159 -> true

NaN

IEEE double, : NaN (Not a Number ). Double , (), double , , , Double.

islnfinite(d) true, double .

islnfinite() true, , Double, .

isNaN(d) true, double .

isNaN() true, , Double, .

Double, , .

class InfNaN {
public static void main(String args[]) { 
Double d1 = new Double(1/0.);
Double d2 = new Double(0/0.);
System.out.println(d1 + ": " + d1.isInfinite() + ", " + d1.isNaN());
System.out.println(d2 + ": " + d2.isInfinite() + ", " + d2.isNaN());
} }

:

:\> java InfNaN
Infinity: true, false
NaN: false, true

Integer Long

Integer - int, short byte, a Long long. Number, Integer Long , , . ( ), . , , .

Character

Character - char. , .

Boolean

Boolean , , boolean , .

Java . . - . , . . - , .

Enumeration

Enumeration , . . hasMoreElements, boolean. true, , false, . nextElement Object, , , .

, Enum, Integer, EnumerateDemo, Enum, . , Enum , Integer.

import java.util.Enumeration;
class Enum implements Enumeration {
private int count = 0;
private boolean more = true;
public boolean hasMoreElements() {
return more;
}
public Object nextElement() {
count++;
if (count > 4) more = false;
return new Integer(count);
} }
class EnumerateDemo {
public static void main(String args[]) { 
Enumeration enum = new Enum();
while (enum.hasMoreElements()) {
System.out.println(enum.nextElement());
}
} }

:

:\> java EnumerateDemo
1
2
3
4
5

Vector

Vector . Vector , . Vector addElement, insertElementAt. Vector , copyInto. , Vector , Contains, indexOf lastIndexOf. lmentAt, firstElement lastElement Vector.

Stack

Stack Vector, " (FIFO). , Stack push pop . peek , . empty true, . search , pop, . , -1.

, , Integer, .

import java.util.Stack;
import java.util.EmptyStackException;                        
class StackDemo {
static void showpush(Stack st, int a) { 
st.push(new Integer(a));
System.out.println("push(" + a + ")");
System.out.println("stack: " + st);
}
static void showpop(Stack st) { 
System.out.print("pop -> ");
Integer a = (Integer) st.pop();
System.out.println(a);
System.out.println("stack: " + st);
}
public static void main(String args[]) { 
Stack st = new Stack();
System.out.println("stack: " + st);
showpush(st, 42);
showpush(st, 66);
showpush(st, 99);
showpop(st);
showpop(st);
showpop(st);
try {
showpop(st);
} 
catch (EmptyStackException e) { 
System.out.println("empty stack");
} }
}

, . , . .

C:\> java StackDemo
stack: []
push(42)
stack: [42]
push(66)
stack: [42, 66]
push(99)
stack: [42, 66,	99]
pop -> 99
stack: [42, 66]
pop -> 66
stack: [42]
pop -> 42
stack: []
pop -> empty stack

Dictionary

Dictionary () , -. , . , put(key, value). get(key). , ( Enumeration) keys elements. size -, , isEmpty true, . remove(key).

HashTable

HashTable Dictionary, . HashTable , . HashTable , ( String). HashTable .

import java.util.Dictionary;
import java.util.Hashtable;
class HTDemo {
public static void main(String args[]) { 
Hashtable ht = new Hashtable();
ht.put("title", "The Java Handbook");
ht.put("author", "Patrick Naugnton");
ht.put("email", "naughton@starwave.com");
ht.put(age", new Integer(30));
show(ht);
}
static void show(Dictionary d) {
System.out.println("Title: " +	d.get("title"));
System.out.println("Author: " + d.get("author"));
System.out.println("Email: " + d.get("email"));
System.out.println("Age: " + d.get("age"));
} }

, show, Dictionary, , ht main.

:\> java HTDemo 
Title: The Java Handbook
Author: Patrick Naughton
Email: naughton@starwave.com
Age: 30

Properties

Properties HashTable, , , , , . getProperty :

getrt("","__");

, , __. , Properties, . Properties Stream ( 13). , :

import java.util.Properties;
class PropDemo {
static Properties prop = new Properties();
public static void main(String args[]) {
prop.put("Title", "put title here");
prop.put("Author", "put name here");
prop.put("isbn", "isbn not set");
Properties book = new Properties(prop);
book.put("Title", "The Java Handbook");
book.put("Author", "Patrick Naughton");
System.out.println("Title: " +
book.getProperty("Title"));
System.out.println("Author: " +
book.getProperty("Author"));
System.out.println("isbn: " +
book.getProperty("isbn"));
System.out.println("ean: " +
book.getProperty("ean", "???"));
} }

prop Properties, Title, Author isbn. Properties book, Title Author. , getProperty . getProperty n. book prop, getProperty , ???:

:\> java PropDemo

Title: The Java Handbook

Author: Patrick Naughton

isbn: isbn not set

ean: ???

StrinsTokenizer

- (tokens). StringTokenizer , . StringTokenizer -. -: , , . , StringTokenizer , nextToken. hasMoreTokens true , . StringTokenizer Enumeration, , hasMoreTokens nextToken hasMoreElements nextElement, .

, = StringTokenizer. = .

import java.util.StringTokenizer;

class STDemo {

static String in = "title=The Java Handbook:" + "author=Patrick Naughton:" + "isbn=0-07-882199-1:" + "ean=9 780078 821998:" + "email=naughton@starwave. corn";

public static void main(String args[]) {

StringTokenizer st = new StringTokenizer(in, "=:");

while (st.hasMoreTokens()) {

String key = st.nextToken();

String val = st.nextToken();

System.out.println(key + "\t" + val);

}

} }

Runtime

Runtime Java. , , , Runtime. , SecurityException. , Runtime , exit(int code).

Java , , . totalMemory freeMemory.

!

, gc. , , gc, free-Memory, , . freeMemory , , .

Java . .

Windows , notepad . Java. - "/" Windows "\".

class ExecDemo {
public static void main(String args[]) {
Runtime r = Runtime. getRuntime();
Process p = null;
String cmd[] = { "notepad", "/java/src/java/lang/Runtime.java" };
try {
p = r.exec(cmd);
} catch (Exception e) {
System.out.println("error executing " + cmd[0]);
}
} }

System

System . System.out.println(). InputStream OutputStream.

currentTimeMillis , 1 1970 .

arraycopy . .

class ACDemo {
static byte a[] = { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74 };
static byte b[] = { 77, 77, 77, 77, 77, 77, 77, 77, 77, 77 };
public static void main(
String args[]) {
System.out.println("a = " + new String(a, 0));
System.out.println("b = " + new String(b, 0));
System.arraycopy(a, 0, b, 0, a.length);
System.out.println("a = " + new String(a, 0));
System.out.println("b = " + new String(b, 0));
System.arraycopy(a, 0, a, 1, a.length - 1);
System.arraycopy(b, 1, b, 0, b.length - 1);
System.out.println("a = " + new String(a, 0));
System.out.println("b = " + new String(b, 0));
} }

, , .

:\> java ACDemo
 = ABCDEFGHIJ
b = 
 = ABCDEFGHIJ
b = ABCDEFGHIJ
 = AABCDEFGHI
b = BCDEFGHIJJ

Java Properties ( ), System.getProperty. System.getProperties() . 4.

4

java.version

Java

java.vendor

,

java.vendor.url

URL

java.class.version

Java API

java.class.path

CLASSPATH

java.home

, Java

java.compiler

JIT

os.name

os.arch

,

os.version

Web-

file.separator

(/ \)

path.separator

(: ;)

line.separator

(\n \r\n)

user.name

user.home

user.dir

user.language

2-

user.region

2-

user.timezone

user.encoding

user.encoding.pkg

, Unicode

Date

Date . , , , , , , . . Date() . .

get set

Date , . get getYear, getMonth, getDate, getDay, getHours, getMi-nutes getSeconds . set setYear, setMonth, setDate, setHours, setMinutes setSeconds . Date long getTime. , 1 1970 .

Date, , long, , . Date , : before, after equals. ,

new Date(96, 2, 18).before(new Date(96, 2, 12)

true, 12- 18-.

Date . , toString Date , , Thu Feb 15 22:42:04 1996. toLocaleString , : 02/15/96 22:42:04. , , toGMTString : 16 Feb 1996 06:42:04 GMT.

Math

Math , . , , : ( 2.72) PI ( 3.14159).

double, , .

, , .

,

, Math , , int, long, float double:

Random

Random . 3.2.1 . , .

Random 5 . nextInt , . , nextLong long. nextFloat nextDouble float double, 0.0..1.0. , , nextGaussian 0.0 1.0.

java.util , ( zip). , , , Java . - .

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