OOP_L16.ppt
- Количество слайдов: 75
Пакет java. lang (класи) Boolean Byte Character Class. Loader Compiler Dоu. Ые Enum Float Inheritable. Thread. Local Integer Long Math Number Object Package Process. Builder Runtimepermission Security. Manager Short Stack. Trace. Element Strict. Math String. Buffer String. Builder System Thread. Group Thread. Local Throwable Void Character. Subset Character. Unicode. Block
Пакет java. lang (інтерфейси) Appendable Char. Sequence Cloneable Comparable Iterable Readable Runnable
Оболонки примітивних типів Number Byte Short Integer Long Float Double
Клас Double (конструктори) Double(double num) Double(String str) throws Number. Format. Exception
Клас Double (методи) byte. Value () static int compare (double num 1, double num 2) int compare. To (Double d) static long double. To. Long. Bits(double num) static long double To. Raw. Long. Bits (double num) double. Value() boolean equals(Object Dоu. Ые. ОЬj) float. Value () int hashcode () int. Value () boolean is. Infinite () static boolean is. Infinite(double num) boolean is. Na. N () static boolean is. Na. N (double num) static double long. Bits. To. Double(long num) long. Valuе () stat. ic double parse. Double(String str) throws Number. Format. Exception short. Value () static String to. Hex. String(double num) String to. String () static String to. String(double num) Static Dou. Ые value. Of(String str) throws Number. Format. Exception
Клас Double (приклад) class Double. Demo { public static void main(String args[]) { Double d 1 = new Double(3. 14159); Double d 2 = new Double("314159 E-5"); System. out. println(d 1 + " = " + d 2 + " -> " + d 1. equals(d 2)); } } 3. 14159 = 3. 14159 -> true
Клас Float (конструктори) Float(double num) Float(float num) Float(String str) throws Number. Format. Exception
Клас Float (методи) byte. Val ие () static int compare (float num 1, float num 2) int compare. To (Float f) double. Value() boolean equals(Object Float. Obj) static int float. Tolnt. Bits(float num) static int float. To. Rawlnt. Bits(float num) float. Value () int hash. Code () static float int. Bits. To. Float(int num) int. Value () boolean islnfinite() static boolean islnfinite (float num) boolean is. Na. N () static boolean is. Na. N (float num) long. Valuе () static float parse. Float(String str) throws Nиmber. Format. Exception short. Valиe() static String to. Hex. String(float num) String to. String () static String to. String (float num) static Float valиe. Of (float num) static Float value. Of(String str) throws Nиmber. Format. Exception
Константи класів Double та Float МАХ_EXPONENT МАХ _VALUE MIN_EXPONENT MIN _NORМAL MIN_VALUE Na. N POSITIVE_INFINITY NEGATIVE_INFINITY SIZE ТУРЕ
Клас Byte (конструктори) Byte(byte num) Byte(String str) throws Number. Format. Exception
Клас Byte (методи) byte. Value () static String to. String(byte num) int соmрате. То (Byte b) static Byte value. Of (byte num) static Byte value. Of (String str) static Byte decode (String str) throws Number. Forma t. Exception static Byte value. Of (String str, int radix) double. Value() throws Number. Format. Exception boolean equals(Object Byte. Obj) float. Value () int hash. Code () int. Value () long. Value () static byte parse. Byte(String str) throws Number. Format. Exception static byte parse. Byte (String str, int radix) throws Number. Format. Exception short. Valuе () String to. String ()
Клас Short (конструктори) Short(short num) Short(String str) throws Number. Format. Exception
Клас Short (методи) byte. Value () short. Value () int compare. To(Short s) String to. String () static String to. String (short num) static Short decode (String str) static Short value. Of (short num) throws Number. Format. Exception static Short value. Of(String str) double. Value() throws Number. Format. Exception boolean equals(Object Short. Obj) static Short value. Of(String str, int radix) float. Value() throws Number. Format. Exception int hash. Code () int. Value () long. Value () static short parse. Short (String str) throws Number. Format. Exception static short parse. Short(String str, int radix) throws Number. Format. Exception static short reverse. Bytes (short num)
Клас Integer (конструктори) Integer(int num) Integer(String str) throws Number. Format. Exception
Клас Integer (методи) static int bit. Count(int num) byte. Valuе () int compare. To (Integer i) static Short decode(String str) throws Number. Format. Exception double. Value () boolean equals (Object Integer. Obj) float. Value () static Integer getlnteger (String property. Name, int default) static Integer getlnteger (String property. Name, Integer default) int hash. Code () static int highest. One. Bit(int num) int. Valuе () long. Value () static int lowest. One. Bit (int num) static int number. Of. Leading. Zeros(int num) static int number. Of. Trailing. Zeros ( int num) static int parselnt (String str) throws Number. Format. Exception static int parse. Int(String str, int radix) throws Number. Format. Exception static int reverse(int num) static int reverse. Bytes (int num) static int rotate. Left(int num, intn) static int rotate. Right(int num, int n) static int signum (int num) short. Value() static String to. Binary. String( int num) static String to. Hex. String (int num) static String to. Octal. String( int num) String to. String () static String to. String (int num, int radix) static Integer value. Of (int num) static Integer value. Of(String str) throws Number. Format. Exception static Integervalue. Of(String str, int radix) throws Number. Format. Exception
Клас Long (конструктори) Long(long num) Long(String str) throws Number. Format. Exception
Клас Long (методи) static int bit. Count (long num) byte. Value () int compare. To (Long l) static Long decode (String str) throws Nuпibеr. Fоrmаt. Exception double. Value() boolean equals(Object Long. Obj) float. Value () static Long get. Long (String property. Name, long dеfаult) static Long get. Long (String property. Name, Long dеfаult) int hash. Code () static int highest. One. Bit (long num) int. Value () long. Value() static int lowest. One. Bit (long num) static int number. Of. Leading. Zeros (long num) static int number. Of. Trailing. Zeros(long num) static long parse. Long ( String str) throws Number. Format. Exception static long parse. Int(String str, int radix) throws Number. Format. Exception static long reverse (long num) static long reverse. Bytes(long num) static long rotate. Left (long num, int n) static long rotate. Right(long num, int n) static int signum (int пит) short. Value () stiitic String to. Binary. String(long num) static String to. Hex. String(long num) static String to. Octal. String(long num) String to. String() static String to. String (long num, int radix) static Long value. Of (long num) static Long value. Of(String str) throws Number. Format. Exception static Long value. Of(String str, int radix) throws Number. Format. Exception
Константи класів Byte, Short, Integer, Long MIN_VALUE МАХ_VALUE SIZE ТУРЕ
Клас Character (конструктор) Character(char ch)
Клас Character (методи) static boolean is. Defined(char ch) static boolean is. Digit (char ch) static Boolean is. Identifier. Ignorable ( char ch) static boolean is. ISOControl (char ch) static Boolean is. Java. Identifier. Part ( char ch) static Boolean is. Java. Identifier. Start ( char ch) static boolean is 1 etter (char ch) static Boolean is 1 etter. Or. Digi t ( char ch) static boolean i. S 1 ower. Case(char ch) static boolean is. Mirrored(char ch) static boolean is. Space. Char (char ch) static boolean is. Title. Case(char ch) static Boolean isunicode. Identifier. Part (char ch) static Boolean is. Unicodeldentifier. Start(char ch) static boolean is. Upper. Case(char ch) static boolean is. Whitespace(char ch) static char to. Lower. Case(char ch) static char to. Title. Case (char ch) static char to. Upper. Case(char ch)
Клас Character (додаткові методи для підтримки Unicode) static int char. Count(int ер) static int code. Point. At (Char. Sequence chars, int loc) static int code. Point. At (char ehars[] , int loc) static int code. Point. Before (Char. Sequence chars, int loc) static int code. Point. Before (char ehars [] , int loc) static boolean is. High. Surrogate (char eh) static boolean is. Low. Surrogate (char eh) static boolean is. Supplementary. Code. Point (int ер) static boolean is. Surrogate. Pair (char high. Ch, char low. Ch) static boolean is. Valid. Code. Point(int ер) static char[] to. Chars(int ер) static int t. OChars (int ер, char target[], int loc) static int to. Code. Point (char high. Ch, char low. Ch)
Константи класу Character МАХ_RADIX MIN_RADIX МАХ _VALUE MIN _VALUE ТУРЕ
Клас Character (приклад) class Is. Demo { public static void main(String args[]) { char a[] = {'a', 'b', '5', '? ', 'A', ' '}; for(int i=0; i<a. length; i++) { if(Character. is. Digit(a[i])) System. out. println(a[i] + " is a digit. "); if(Character. is. Letter(a[i])) System. out. println(a[i] + " is a letter. "); if(Character. is. Whitespace(a[i])) System. out. println(a[i] + " is whitespace. "); if(Character. is. Upper. Case(a[i])) System. out. println(a[i] + " is uppercase. "); if(Character. is. Lower. Case(a[i])) System. out. println(a[i] + " is lowercase. "); } } } a is a letter. a is lowercase. b is a letter. b is lowercase. 5 is a digit. A is a letter. A is uppercase. is whitespace.
Клас Boolean (конструктори) Boolean(boolean bool. Value) Boolean(String bool. String)
Клас Boolean(методи) boolean. Value() int compare. To(Boolean b) boolean equals(Object bool. Obj) static boolean get. Boolean ( String property. Naтe) int hash. Code () static boolean parse. Boolean(String str) String to. String() static String to. String(boolean bool. Val) static Boolean value. Of (String bool. Striпg)
Клас Void Поле TYPE
Клас Process (методи) void destroy () int ext. Value () Input. Stream get. Error. Stream() Input. Stream get. Output. Stream() Oиtput. Stream get. Output. Stream() int wait. For () throws Interrupted. Exception
Клас Runtime (методи) void add. Shиtdown. Hook(Thread thrd) Process ехес (String prog. Name) throws IOException Process exec(String prog. Name, String eпviroпmeпt[]) throws IOException Process exec(String com. Liпe. Array[], String eпviroпmeпt[]) throws IOException void ех. Н (int exit. Code) long free. Memory() void gc () static Rиntime get. Rиntime() void halt (int code) void load (String library. File. Name) void load. Library (String library. Name) Boolean remove. Shиtdown. Hook (Thread thrd) void run. Finalization () long total. Memory() void trace. Instructions (boolean trace. On) void trace. Method. Calls (boolean trace. On)
Клас Runtime (приклад 1, управління пам’яттю) class Memory. Demo { public static void main(String args[]) { Runtime r = Runtime. get. Runtime(); long mem 1, mem 2; Integer someints[] = new Integer[1000]; System. out. println("Total memory is: " + r. total. Memory()); mem 1 = r. free. Memory(); System. out. println("Initial free memory: " + mem 1); r. gc(); mem 1 = r. free. Memory(); System. out. println("Free memory after garbage collection: “ + mem 1); for(int i=0; i<1000; i++) // allocate integers someints[i] = new Integer(i); mem 2 = r. free. Memory(); System. out. println("Free memory after allocation: “ + mem 2); System. out. println("Memory used by allocation: “ + (mem 1 -mem 2)); // discard Integers for(int i=0; i<1000; i++) someints[i] = null; r. gc(); // request garbage collection mem 2 = r. free. Memory(); System. out. println("Free memory after collecting" + " discarded Integers: " + mem 2); } }
Клас Runtime (приклад 2 ) class Exec. Demo { public static void main(String args[]) { Runtime r = Runtime. get. Runtime(); Process p = null; try { p = r. exec("notepad"); } catch (Exception e) { System. out. println("Error executing notepad. "); } } }
Клас Runtime (приклад 3) class Exec. Demo. Fini { public static void main(String args[]) { Runtime r = Runtime. get. Runtime(); Process p = null; try { p = r. exec("notepad"); p. wait. For(); } catch (Exception e) { System. out. println("Error executing notepad. "); } System. out. println("Notepad returned " + p. exit. Value()); } }
Клас Process. Builder (конструктори) Process. Builder(List<String> args) Process. Builder(String … args)
Клас Process. Builder (методи) List<String> command() Process. Builder command(List<String> args) Process. Builder command(String args) File directory () Process. Builder directory(File dir) Map<String, String> environment() boolean redirect. Error. Stream() Process. Builder redirect. Error. Stream ( boolean merge) Process start() throws IOException
Клас Process. Builder (приклад) class PBDemo { public static void main(String args[]) { try { Process. Builder proc = new Process. Builder("notepad. exe", "testfile"); proc. start(); } catch (Exception e) { System. out. println("Error executing notepad. "); } } }
Клас System (методи 1) static void arraycopy (Obj ect source, int source. Start, Obj ect target, int target. Start, int size) static String clear. Property(String which) static Console console() static long current. Time. Millis() static void exit (int exit. Code) static void gc () static Map<String, String> getenv () static String getenv(String which) static Properties get. Properties() static String get. Property(String which,
Клас System (методи 2) static Security. Manager get. Security. Manager() static int identity. Hash. Code(Object obj) static Channel inherited. Channel() throws IOException static void load (String library. File. Name) static void load. Library (String library. Name) static void map. Library. Name(String lib) static long nano. Time () static void run. Finalization () static void set. Err (Print. Stream e. Stream) static void setln (Input. Stream i. Stream) static void set. Out(Print. Stream o. Stream) static void set. Properties(Properties sys. Properties) static String set. Property(String which, String v) static void set. Securi ty. Manager (Security. Manager sec. Man)
Клас Object (методи) Object clone() throws Clone. Not. Sиpported. Exception boolean eqиals(Object object) void finalize() throws Throwable final Class <? > get. Class () int hash. Code ( ) final void notify () final void notify. All () String to. String () final void wait () throws Interrиpted. Exception final void wait (long milliseconds) throws Interrиpted. Exception final void wait (long тillisecoпds, int пaпosecoпds) throws Interrиpted. Exception
Клас Class (1) static Class<? > for. Name(String name) throws Class. Not. Found. Exception static Class<? > for. Name(String name, Ьооlеаn how, Class. Loader ldr) Throws Class. Not. Found. Exception <А extends Annotation> А get. Annotation(Class<A> аnno. Туре) Annotation[ ] get. Annotations() Class<? > [ ] get. Classes () Class. Loader get. Class. Loader() Constructor<T> get. Constructor(Class param. Types) throws No. Such. Method. Exception, Security. Exception
Клас Class (2) Constructor<? >[] get. Constructors() throws Security. Exception Annotation[] get. Declared. Annotations() Constructor<? >[] get. Declared. Constructors() throws Security. Exception Field[] get. Declared. Fields() throws Security. Exception Method[] get. Declared. Мethods() throws Security. Exception Field get. Field (String field. Name) throws No. Sиch. Method. Exception, Security. Exception Field[] get. Fields() throws Security. Exception Class<? >[] get. Interfaces()
Клас Class (3) Method get. Method(String meth. Name, Class<? > param. Types) throws No. Such. Method. Exception, Security. Exception Method [] get. Methods () throws Security. Exception String get. Name () Protection. Domain get. Protection. Domain() Class<? super Т> get. Superclass () Boolean islnterface() T newlnstance () throws Illegal. Access. Exception, Instantiation. Exception String to. String ()
Клас Class (приклад) class X { int a; cl. Obj = y. get. Class(); // get Class reference float b; System. out. println("y is object of type: " + } cl. Obj. get. Name()); class Y extends X { cl. Obj = cl. Obj. get. Superclass(); double c; System. out. println(“y's superclass is " + } cl. Obj. get. Name()); class RTTI { } public static void main(String args[]) { } X x = new X(); Y y = new Y(); Х is object of type: Х Class<? > cl. Obj; y is object of type: y cl. Obj = x. get. Class(); // get Class reference y's superclass is x System. out. println("x is object of type: " + cl. Obj. get. Name());
Клас Class. Loader Абстрактний клас. Визначає як завантажуються класи
Клас Мath Трансцедентні функції Експоненціальні функції Функції заокруглення Інші методи
Клас Мath (трансцедентні функції) функції static double sin (double arg) static double cos (double arg) static double tan (double arg) static double asin (double arg) static double аcos (double arg) static double atan 2 (double х, double у) static double sinh (double arg) static double cosh (double arg) static double tanh (double arg)
Клас Мath (експоненціальні функції) функції static double cbrt (double arg) static double ехрml (double arg) static double log 10 (double arg) static double loglp (double arg) static double pow(double у, double х) static double sca 1 b (double arg, int factor) static fl 0 at scalb (f 1 oat arg, int factor) static double sqrt (double arg)
Клас Мath (функції заокруглення) заокруглення static int abs (int arg) static long abs (long arg) static float abs (float arg) static double abs (double arg) static double сеil(double arg) static double floor(double arg) static int mах (int х, int у) static long mах (long х, long у) static float mах (float х, float у) static double max(double х, double у) static int min(int х, int у) static long min(long х, long у) static float min(float х, float у) static double min(double х, double у)
Клас Мath (функції заокруглення) заокруглення static static static double next. After(double arg, double toward) float next. After (float arg, double toward) double next. Up (double arg) float next. Up (float arg) double rint (double arg) int round (float arg) long round (double arg) float ulp (float arg) double ulp (double arg)
Клас Мath (інші методи) методи static static static double copy. Sign(double arg, double sigпarg) float copy. Sign (float arg, float signarg) int get. Exponent (double arg) int get. Exponent (float arg) double IEEEremainder(double divideпd, double divisor) hypot(double sidel, double side 2) double random () float signum (double arg) float signum (float arg) double to. Degrees(double angle) double to. Radians(double aпgle)
Клас Мath (приклад) class Angles { public static void main(String args[]) { double theta = 120. 0; System. out. println(theta + " degrees is " + Math. to. Radians(theta) + " radians. "); theta = 1. 312; System. out. println(theta + " radians is " + Math. to. Degrees(theta) + " degrees. "); } } 120. 0 degrees is 2. 0943951023931953 radians. 1. 312 radians is 75. 17206272116401 degrees.
Клас Strictмath Визначає повний набір математичних методів паралельний доступному в Мath
Клас Compiler Підтримує створення оточень Java
Інтерфейс Runnable void run ()
Клас Thread ( ) Thread(Runnable thread. Ob, String thread. Name) Thread (String thread. Name) Thread(Thread. Group group. Ob, Runnable thread. Ob, String thread. Name) Thread (Thread, Group group. Ob, String thread. Name) МАХ PRIORITY MIN PRIORITY NORМ PRIORITY
Клас Thread static int active. Count() void check. Access () static Thread current. Thread () static void dump. Stack () static int enumerate (Thread threads [] ) static Map<Thread, Stack. Trace. Element[]> get. All. Stack. Traces() Class. Loader get. Context. Class. Loader()
Клас Thread static Thread. Uncaught. Exception. Handler get. Default. Uncaught. Exception. Handler() Thread. Uncaught. Exception. Handler get. Uncaught. Exception. Handler() long get. ID () final String get. Name () final int getpriori ty () Stack. Trace. Element[] get. Stack. Trace()
Клас Thread. State get. State() final Thread. Group get. Thread. Group () static boolean holds. Lock(Object о. Ь) void interrupt () static boolean interrupted () final Boolean is. Alive ()
Клас Thread final Boolean is. Daemon () boolean is Interrupted () final void join () throws Interrupted. Exception final void join (long millisecoпds) throws Interrиpted. Exception final void join (long millisecoпds, int nanosecoпds) throws Interrupted. Exception void run () void set. Context. Class. Loader (Class. Loader cl)
Клас Thread final void set. Daemon (boolean state) static void set. Default. Uncaught. Exception. Handler ( Thread. Uncaиght. Exception. Handler е) void set. Uncaught. Exception. Handler ( Thread. Uncaught. Exception. Handler е) final void set. Name (String thread. Name) final void set. Priority (int priority) static void sleep (long milliseconds) throws Interrupted. Exception
Клас Thread static void sleep (long millisecoпds, int nanosecoпds) throws Interrupted. Exception void start () String to. String() static void yield ()
Клас Thread. Group(String group. Name) Thread. Group(Thread. Group parent. Ob, String group. Name)
Клас Thread. Group int active. Count ( ) int active. Group. Count () final void check. Access () final void destroy () int enumerate(Thread group [ ] ) int enumerate (Thread group[], boolean all) int enumerate (Thread. Group group[] , boolean all)
Клас Thread. Group final int get. Max. Priority () final String get. Name () final Thread. Group getparent () final void interrupt () final boolean is. Daemon () boolean is. Destroyed () void list ()
Клас Thread. Group final boolean parent. Of ( Thread. Group group) final void set. Daemon (Boolean is. Daemon) final void set. Max. Priority(int priority) String to. String () void uncaught. Exception(Thread thread, Throwable е)
Клас Thread. Local Створення локальних змінних потоків
Клас Inheritable. Thread. Local Створення локальних змінних потоків (можливість успадкування)
Клас Package <А extends Annotation> А get. Annotation(Class<A> аnnо. Туре) Annotation[ ] get. Annotations() Annotation[ ] get. Declared. Annotations() String get. Implementation. Title() String get. Implementation. Vendor() String get. Implementationversion() String get. Name () static Package get. Pac ge(String pkg. Naтe)
Клас Package static Package get. Pacage(String pkg. Name) static Package [] getpackages () String get. Specification. Title() String get. Specification. Vendor() String get. Specification. Version() int hash. Code () boolean is. Annotation. Present(Class<? extends Annotation> аnnо)
Клас Package boolean is. Compatible. With(String ver. Num) throws Number. Format. Exception boolean is. Sealed() boolean is. Sealed(URL url) String to. String ()
Клас Package boolean is. Compatible. With(String ver. Num) throws Number. Format. Exception boolean is. Sealed() boolean is. Sealed(URL url) String to. String ()
Клас Package class Pkg. Test { public static void main(String args[]) { Package pkgs[]; pkgs = Package. get. Packages(); for(int i=0; i < pkgs. length; i++) System. out. println( pkgs[i]. get. Name() + " " + pkgs[i]. get. Implementation. Title() + " " + pkgs[i]. get. Implementation. Vendor() + " " + pkgs[i]. get. Implementation. Version() ); } }
Клас Stack. Trace. Element boolean equals(Object о. Ь) String get. Class. Name () String get. File. Name () int get. Line. Number () String get. Method. Name () int hash. Code () boolean is. Native. Method() String to. String ()
Клас Enum protected final Object clone () throws Clone. Not. Supported. Exception final int compare. To (Е е) final boolean equals(Object obj) final Class<E> get. Declaring. Class() final int hash. Code() final String nаmе ()
Клас Enum final int ordinal() String to. String () static <Т extends Еnum<Т» Т value. Of(Class<T> e_type, String nаmе)
Інтерфейси Comparable Appendable Iterable Reada. Ьle
Вкладені пакети java. lang. annotation java. lang. instrument java. lang. management java. lang. reflect
OOP_L16.ppt