Java Learning next Book

Source: Internet
Author: User
Tags comparable event listener instance method object serialization

Summarize some of this week's content '

Dates: Date creates an object for the current system object. Used to save dates

Clendar operation of the date

SimpleDateFormat used to swap strings with dates

Wrapper class: Apply object-oriented principles to 8 basic types in Java and develop 8 corresponding classes.

Boxing: Putting data of a value type into a reference type

Unpacking: Putting data of reference types into value types

Packing and unpacking will have an efficient amount of loss, and in development try to avoid packing and unpacking

Boxing and unpacking is because you want to use object mode to handle basic types

How to implement random numbers: Seed + time + algorithm = = random number

Regular expression: The rule used to validate a string

Matcher M=pat.matcher (target) object matches the target to get the matching result;
(M.matches ()) {match, mismatch} using Matchees to verify whether the match was successful

Tool class:

Collections class:
Shuffle () loop randomly arranges elements in the collection; Collections.shuff (numbers) for (integer item:numbers) {Item}

Reverse (numbers) ordered in reverse order, and the elements of the current collection are arranged in reverse

Sort (numbers) ascending sorting student class implementation comparable

Classes that implement the comparable interface can use only one sort scheme, which is called a "natural comparison" scenario.

If you want to implement multiple scenarios for sorting, you need to use the comparator interface

Sorting and collections sorting methods in arrays are almost nothing more than manipulating arrays.

File class: Information that is used to read files or folders (excluding content)
Files are stored on the hard disk and can persist data. File=new file (path)
Absolute path: The path to find from a system drive letter.
Relative path: Relative to the working directory.
Typically, access to files within a project uses relative paths, and an absolute path is used externally.
Exists () determines if there is a GetPath get path absolutepath absolute path.
Double KB variable. Length () Get File size/1024.0
Long mm =f.lastmodified () Date Modified
F.delete () Delete file,

To access a folder:
F.list () is the return array;
F.listfiles () array of all file names;
Isdirectory () Boolean type find out if it is a folder
Listroots access to an array of system disks;

Stream: is a channel that links memory and other media.

Classification of streams:
According to the direction: input stream output stream-relative and memory-"output"--input;
According to the data carrier to divide: byte stream and character stream;

java.io

IO: Inputs input outputs output
Reader: Character input stream
InputStream: Input byte stream
OutputStream: Byte output stream
Writer: Character output stream

Media + abstract class name
FileReader


Reading data from a text file: direction: Input data carrier: Word Fu Jiezi: File
The Read method: Moves the current position to the next position, and returns the character encoding of the position,


Object serialization: Use binary format for object data, save to Meson
Direction: Output
Data carrier: bytes
ObjectOutputStream
Object deserialization: Data from the binary format of the object's data is read into the object
Objextinputstream

Interface: console, form, Web page.
Javax.swing: Some implementation classes are provided, most of which start with J and implement a cross-platform unified interface.
java.awt: provides some abstract classes, as well as some implementation classes, with poor cross-platform features.
Coponent: Shown on page 391 of the book.
Container: JFrame \jpanel

JFrame: Cross-platform, form swing program to display the interface, at least one form, the form is the largest container. Need new setvisible (true) to create the form and finish creating setlayout (NULL)
Set size setsize (width, height) set position setlocationrelativeto (NULL)
Set font SetTile ("")
Set image Image N =f.gettoolkit () getimage-seticonimage (n)

JLabel: Tags such as password account LBL

JTextField: Single-line text box txt

JTextArea: Multi-line text box txt
Password box: jpasswordfield-txt

Button: jbutton-btn

Drop-down list: Jcombobox-combo

Radio Box: JRADIOBUTTON-CB

Multi Box: Jchackbox-ob

Event: One thing happens, an event is an object, a different thing. are objects of different classes.

Event Source: The Origin of the event (who has an event);

The event source can be obtained from any one of the event objects.

Any event class inherits the abstract class event. and the class name: What happened + event.

407 Books

Event listener: Post-processing when something happens.

An event listener is an interface in which each listener is targeted at only one event.

The listener interface is named by: Things +listener.

Register an event: Add a listener: A listener is added for a component, and when the corresponding event occurs, the corresponding method in the listener is run, and the event object is passed as a parameter


JFrame: There is an instance method of Dispose, which indicates that the form is closed.

The anonymous inner class constructor has no parameters and can use the attributes of the outer class;


Joptionpane: Options panel, which provides a number of static methods for pop-up prompts. Show me ' message type.

ComPonent: Components

Container: Container JFrame,
JDialog: dialog box that must be ejected by the form
JPanel: Panel, cannot eject independently, must be placed in other containers,


Layout: Layouts Refer to Component display sub-scenarios within a container

Nill: Empty layout, all component locations are absolute locations

CardLayout: Card layout, the container internal component only displays one of them, can make his method switch display.

Java Learning next Book

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.