Java Learning Notes (13) Collection framework, user interface

Source: Internet
Author: User

A collection is an object that stores, retrieves, and transmits data. Consists of a set of classes and interfaces.

Features: type can be different, length variable, space is not fixed.

The storage type of the object:
Set: In general there is no order and cannot be duplicated.
List: Ordered, with duplicate objects, implementation classes typically support NULL elements.
MAP: Key-value pairs, keys, values can not be repeated, one-way relationship.

ArrayList: Realized by array, continuous space, high query efficiency.
LinkedList: Realized by the chain list, increase, delete, change the efficiency high.

Generics: Allows you to specify type-formal parameters when defining classes, interfaces. Guarantees the security of the element type in the collection.

public class arraylistdemo{
public static void Main (String [] args) {
list<integer> li = new arraylist<integer> ();
Add to
Li.add (5);
Li.add (New Integer (4));
Li.add ("six");
Delete
Li.remove (1);//subscript indicates
Get element
for (int i = 0; i < li.size (); i++) {
SYSTEM.OUT.PRINTLN (i + "=" + Li.get (i));
}
}
}

The "<Integer>" in the code represents generics, and Li.add ("six") is commented out at compile time.


Tool classes: Collections, arrays these two classes provide wrapper implementations, data structure algorithms, and array-related applications. Provides a large number of static methods, in the operation of the collection and array, can greatly reduce the programmer coding, improve development efficiency, improve code performance.

Swing components are new GUI components developed on the basis of AWT.

The MVC architecture, which divides the presentation layer into 3 categories: Model (Save), view (Explicit), controller (processing).

The swing view consists of containers and components, which are special types of components designed to place other components.

Components: Content, appearance display, behavior.

Heavyweight components: Jframe (Form), JDialog (dialog box), JWindow (window), JApplet (applet)
Lightweight components: Jpanel (panel), JSplitPane (divider pane), JScrollPane (scroll pane), Jtabbledpane (tab pane), JRootPane (toolbar), and some specialized containers.

Layout Manager:
Streaming layout Manager (left-to-right), the JPanel component defaults to this layout manager
Border layout Manager (in the Cardinal, JFrame), this layout manager is used by default
Grid layout Manager (rows and columns)
Box Layout Manager (vertical or horizontal)
Card layout manager, grid package layout manager, cascading layout Manager

JMenuBar menu, JMenu, JMenu Item submenu

AWT Swing
A collection of user interface elements that are more convenient and rich in rough appearance
Platform inconsistencies are less dependent on the underlying platform, and fewer bugs are associated with the platform
Low operating efficiency, not suitable for complex programs to the user the same feeling of the platform
Low development efficiency No peer component

Import Javax.swing.JFrame;

public class Login extends JFrame {
Public Login () {
Title
Settitle ("login");
Form size
SetSize (200,300);
Form Close
Setdefaultcloseoperation (Exit_on_close);
Form Center
Setlocationrelativeto (NULL);
Form visible
SetVisible (TRUE);
}
public static void Main (String [] args) {
Instantiate an Object
New Login ();
}
}

Java Learning Notes (13) Collection framework, user interface

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.