Core Java- concept Chapter
If you need to know which Unicode characters belong to the Java alphabet, you can use the Javaidentifierstart and Javaidentifierpart methods of the Charactor class to detect
Const is a reserved word for Java, but it is not currently used
An integer that is 0 apart will produce an exception
The core concept of Java: interface (interface)Interfaces are at the same level as classes, and in fact, interfaces are a special kind of abstract class.Such as:Interface ia{}Public interface: Open InterfaceSimilar to a class, a file can have only one public interface and is the same as the file name.A public interface and a public class cannot be defined in a file at the same time.In an interface, all meth
Well known in. NET, the key generated by the RSA class is in XML format, while other languages such as Java generally use the PKCS8 format key, JavaScript generally uses the PKCS1 format. We in the development process is likely to encounter the need to interface with other languages developed API, if we encounter RSA encryption and decryption, we must ensure that key is the same, in order to ensure the correct processing of data, we definitely need to
) proxy.newproxyinstance ( fly.getclass (). getClassLoader (), new class[] {flyable.class}, new Objecthandler (fly)); } public static void Main (string[] args) { flyable fly = Flyfactory.getflayimpl (); Fly.addwing (null); System.out.println (Fly.fly ());} }Core Class Description:The JDK provides a class named Proxy.newproxyinstance (All-in-one). Where is the first parameter for the loader th
Exception handlingThe parent class in the exception structure Throwable class, its Exceptionlei class and the error class. What we can catch in the program is the subclass exception of exception.Error at System level: Error in Java Runtime Environment, we are not controllable.Exception is a program-level error: we can control it. 1) catch Exceptions in two ways: one is to add Try-catch to catch the exception, and the other is to declare the exceptio
the source file. If you do not place the package statement in the source file, the class in the source file is placed in a default packet.The compiler does not check the directory structure when compiling the source files. So as long as the source file is not dependent on other packages, the compilation error does not occur even if it is not in the declared package, but a run error occurs because the virtual machine cannot find the file.Package Scope:The parts marked as public can be used on an
Java core programming-byte stream of IO stream (2), javaio
1. byte stream
A 1.1-byte stream is a stream that operates byte. Byte streams can operate on any data, such as media data, music, movies, and images. Of course, they can also operate on characters. Byte stream is based on byte stream, we know that a byte is 8 binary bits, a byte corresponds to an English character in the UTF-8, people found that usi
Running a Java program in a Web page is called an applet.ReflectionThis feature is used extensively in JavaBeans, which is the architecture of Java components.A program capable of analyzing classes is called reflection (reflective). The function of the reflection mechanism and its powerful, as can be seen below, the reflection mechanism can be used to:
Ability to analyze classes in the run
View obj
throws interrupterexception{ Sleep (delay);}10.synchronized keywords Public synchronized Voi Method () { method body}Equivalent to Public void method () { this. Intrinsiclock.lock (); Try { method body }finally{ this. Intrinsiclock.unlock ( ); }}11. Use Object Lock public class bank{ public void transfer (int from, int to, int mount) { synchronized -=amount; Accounts[to] +=amount; } System.out.println (...); private double [] Account; p
have different implementationsMethod definitions in Java--------------------------1) A method allows the presence of multiple modifiers, with no order of precedence between multiple modifiers2) The return type is located after the modifier, and a method must have a return typeFor methods that do not return a value, the return type is void3) When there is a return value in the method, each branch in the method is required to have a return to ensure th
main element between, child elements and child elements between the space also forget. If you only want to get child elements, you can do this:NodeList children = Root.getchildnodes ();for (int i=0;iNode child = Children.item (i);if (child instanceof Element) {Element childelement = (element) child;...}}This processing is still very troublesome, this is why the subsequent introduction of the DTD, the DTD can be used to standardize the content of XML, reduce some unnecessary validation process.L
Nio:new IOStarting with JDK1.4, the new IO, which can map a disk file into memory, we then read the data in memory.stored in the Java.nio packageJava NIO (new IO) is a new IO API introduced by the Java1.4 version, which can replace the standard Java IO API, which is now primarily used in servers, and is sufficient for us to write code that still uses traditional IO.Java NiO provides a different way of working with iOS than standard IO:Channels and buf
This section begins the Java Multithreaded Programming learning, the basic concepts of the operating system, processes, threads are no longer mentioned, just understand Java for multithreaded programming support.First, inherit the thread class to create threadsThe Java language uses the thread class to represent threads, and classes that represent threads can imp
Thread pool is a key point to be mastered in multi-threaded learning.The cost of starting a new thread is higher because it involves interacting with the operating system. In this scenario, using the thread pool can improve performance, especially if you need to consider using a thread pool when you want to create a lot of short-lived threads in your program.I. How do I create a thread pool??Before Java5, the thread pool was developed manually, and from Java5 onwards,
As a business developer, there are few technologies that can be used at work. Although usually always say what, multi-threading, concurrency, injection, Attack! But in practical work, these things are not necessarily used. Because the framework we used has already done that.For example, web development, there are a lot of requests coming in, supposedly, we should consider concurrency problems. But in fact, Spring receives the request, after assigning to the controller, it is already thread-safe,
loaded by the sub-classloader cannot be converted to each other.
It should be emphasized that all variables after the overloaded class is reinitialized, so some important data variables must be managed by the parent classloader.
This method has some disadvantages. The core logic is combined to separate the variables, which affects the structure of the application.
At present, this method should be used in a message service, mainly to avoid restarting
change methodThis is obviously more complex than providing a simple public data field, but it also has significant advantages(1) Can change the internal implementation, in addition to the method of the class, does not affect the other code(2) The Change method can perform error checking, but assigning a value directly to a domain will not be processedNote Do not write accessor methods that return references to mutable objects.3.4 Class-based access rights(1) A method can access the private data
Core java Chapter 4 notes, corejava
Import java. util. *; public class Employee {private static int nextid = 1; private String name; private double salary; private int id; public Employee (String n, double s) {name = n; salary = s; id = 0;} public String getname () {return name;} public double getsalary () {return salary;} public int getid () {return id ;} public
(final)Final Double per_inch=2.54;2. strictfp-represents an accurate floating-point calculation where the intermediate process does not truncate// The following method is calculated using the exact floating point number Private double Calculate (double double double z) { return x * Y/ z; }3. Use String.Equals () to determine if the strings are equal, not "= =" 4. "" represents an empty string, and Null indicates that the string variable is not associated with any string obje
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.