Javase Learning Summary 11th Day _ Development tools & API Common Objects 1

Source: Internet
Author: User

11.01 Introduction to common development tools

1: Operating system comes with Notepad software

2: Advanced Notepad software Example: Editplus,notepad++,ultraedit

3: Integrated development Environment IDE (Integrated development environment)

This software is an application for a program development environment, typically including code editors, compilers, debuggers, and graphical interface tools.

Integration of code writing functions, analysis functions, compile functions, debugging functions and other integrated development software. Software that has this feature can be called an IDE.

Example: Jcreator,jbuilder,netbeans,jdeveloper,eclipse,myeclipse

11.02 Overview of Eclipse and MyEclipse

Eclipse is an extensible, open-source IDE.

Eclipse Features: free, plain Java language Authoring, no installation, strong extensibility

Because it is written in the Java language, you need to provide it with JDK and JRE

MyEclipse: A plug-in feature added on the eclipse basis, charging the plugin, and providing a powerful system architecture platform in web development

Download installation and uninstallation of 11.03 eclipse

Download: http://eclipse.org/

Installation:

The green version of the decompression can be used (Eclipse)

Installation version double-click to run, always next (JDK)

Unloading:

The green version of the folder can be deleted directly

Install professional uninstall software or Control Panel add remove Program

11.04 How to write a HelloWorld case in eclipse

Select workspace: The workspace is actually the directory where we write the source code

Use Eclipse to complete a HelloWorld case

Code with project as base unit

1. Create a Project 2. Create a package 3. Create Class 4. Write code

11.05 how to compile and run programs in eclipse

Compile: Auto compile, compile at the moment of saving

Run:

1. Click the green Inside triangle button run

2. Click Run under the Run menu. You can also use shortcut keys Ctrl+f11

3. Select the file you want to run or right-click →run As→java Application in the content of the file you want to run. When you see the console, it's the one that comes with eclipse.

11.06 Eclipse's Chinese and grammar check tips

Chinese: Install plug-ins using Dropins

Starting from Eclipse3.5, there is a dropins directory under the installation directory, just unzip the plugin and put it in the directory.

Similarly, uninstalling plugins in this way is also particularly convenient, recommended this way

Both Chinese and English versions can be used

Source code Syntax Check

Red wavy line: Wrong source code

Yellow wavy lines: Unused members or members with security implications

11.07 Eclipse's Windows and Views overview

Windows: Every basic form is called a window

Packageexplorer: Show project Structure, packages, classes, and resources

Outline: Display the structure of the class, easy to find, identify, modify

Console: The results of the program run are displayed in this window

Problems: Shows all syntax and where the error is located

Hierarchy: Show Java inheritance hierarchy, press F4 when class is selected

View: is a combination of some windows

Example: Java view, Debug view

11.08 The basic configuration of the Eclipse workspace

1: The program compiles and runs the environment configuration (generally does not change)

Window→preferences→java

Compiler: The highest version is selected by default for the compilation environment.

Installed JREs: The running environment will find the JDK installed by default. We recommend that you configure the environment variables for Java.

Use a lower version at compile time, and the runtime uses a high version to

Compile-time using a high version, run-time using a low version can not

Recommended compile and run versions are consistent

2: How to get rid of default annotations

Window→preferences→java→code Style→code Templates

Choose what you don't want, edit it on the right

Note: Delete Only the comments section, not the comments section.

3: Line number display and hide

Display: In the left-most blank area of the code area, right-click →show line Numbers

Hide: Do the above action again.

4: Font size and color

A.java font size and color for code area: window→preferences→general→appearance→colors and Fonts→java→java Edit Text font

B. Console: Window→preferences→general→appearance→colors and Fonts→debug→console font

C. Other documents: Window→preferences→general→appearance→colors and Fonts→basic→text Font

5: Form messed up, reset form Window→reset perspective

6: Display console window→show View→console

11.09 use of content secondary keys in eclipse

alt+/: Content-assisted Keys act as Hints

main+alt+/: Show Main method

syso+alt+/: Show Output statement

Give other hints

11.10 Use of shortcut keys in eclipse

Common shortcut keys

Ctrl+shift+f: Formatting

Ctrl+shift+o: Importing Packages

Comments:

ctrl+/: single-line comment

ctrl+shift+/: Multiline Comment

Ctrl+shift+\: Canceling multiple lines of comment

Select Code ALT + up/down ARROW: Code moves up and down

Check the class name (F3 or CTRL + mouse click): View Source code

Automatic generation of construction methods and Get_set methods in 11.11 Eclipse

Automatic generation of construction methods

1. Non-parametric construction method right-→source→generate constructors from superclass in the code area

2. With the parameter construction method in the code area right-click →source→generate constructors using Fields→finish

Auto-Generate Get/set method: Right-→source→generate Getters and Setters in the code area

11.12 in eclipse to inherit abstract classes or implement Interface simplification

Inherit an abstract class, or implement an interface

1: The previous procedure writes the class first, then inherits the class or implements the interface in the class

2: Now practice when creating a class, select the class to inherit or the interface to implement

object is the parent class of all classes, and all classes are directly or indirectly inherited from Object

Override is an annotation that shows that this method overrides the parent class's

11.13 Eclipse to write a standard student class and its test

11.14 Eclipse writing high Jump Interface abstract animal class and specific animal sub-category

11.15 How to build a jar package in Eclipse and import it into a new project

Jar is a compressed package of multiple class files

Jars make it easy to use what someone else has written.

Hit Jar package: Select item → right →export→java→jar file→ Specify a path and a name yourself →finish

Use the jar package: Copy the jar package and paste it under the project path you want to use. Select the jar package, right-click Build Path→add to build path

11.16 Eclipse How to make help documents and use JAR packages

Authoring Help documents: Select items → right-click →export→java→javadoc→finish

11.17 How to delete projects and import projects in eclipse

Delete items: Select items → right-click →delete 1. Remove from Project Area 2. Remove from hard disk

Import Project: In the project area right-click →import→general expand →existing Projects into Workspace→next and select the project you want to import. Note: The project name is selected

11.18 Eclipse Import Project to pay attention to the small issues

How to view the path of a project: Check → right click →properties→resource→location

Issues to be aware of when importing projects:

1. Projects with the same name cannot appear in the project area (new or imported)

2. The folder that you create yourself is not imported as a project.

To modify a project question:

1. Do not arbitrarily modify the project name

2. If you really want to modify, do not forget the configuration file. <name> in Project change this to your renamed name </name>

11.19 considerations for receiving projects in Eclipse development

Once the same project is received again, first go to the storage directory to delete the original item, then re-store, and finally refresh the project can

11.20 Basic use of debug in eclipse

The role of debug: Debug programs, view program execution flow

What is a breakpoint: is a marker that indicates where to start looking at the program

How to set Breakpoints: Double-click on the leftmost side of the first statement of the method

Where to set breakpoints: on the first valid statement of each method, add

How to run a program after setting a breakpoint: In the code area → right-click →debug As→java appliaction

See which places:

Debug: Place the breakpoint test by pressing the F6 key, or click OK. See the execution of a row at a time.

Variables: Viewing variable variations of a program

Fordemo: The source file being viewed

Console: Consoles

How to remove Breakpoints:

1. Double-click on the breakpoint again

2. Find the debug view, find the breakpoints click, then see all the breakpoints, and finally click on the fork to delete all breakpoints

11.21 Eclipse view parameter passing issues in Java

11.22 API Overview

API (Application Programming Interface) application programming interface

API is the Java class for the various functions provided in the JDK

11.23 learning the similarities and differences between Chinese and programming languages

The same point: basic grammar, a large number of idioms

Different points: Learning Chinese must be learned before using, learning to program can be used in the current learning

11.24 an overview of the object class

An overview of the object class:

Class Object is the root class of a class hierarchy. Each class uses Object as a superclass. All objects, including arrays, implement methods of this class.

Constructor method: Public Object (), the constructor of the subclass is accessed by default for the non-parametric construction method of the parent class

11.25 the Hashcode () method of the object class

public int hashcode (): Returns the hash code value of the object

The Hashcode method returns different integers for different objects, typically by converting the object's internal address to an integer.

Cases:

1 Student s1 = new Student (); 2 System.out.println (S1.hashcode ());//185644633 Student s2 = new Student (); 4 System.out.print ln (S2.hashcode ());//238218385 Student s3 = s1;6 System.out.println (S3.hashcode ());//18564463

11.26 the GetClass () method of the object class

Public final class<?> getclass (): Returns the run-time class for this Object

Cases:

1 Student s1 = new Student (); 2 Class C = S1.getclass (); 3 String name = C.getname (); 4 System.out.println (name);//com.test.s TUDENT5//Chained programming 6 String str = S1.getclass (). GetName (); 7 System.out.println (str);//com.test.student

11.27 the ToString () method of the object class

public string toString (): Returns the string representation of the object

The ToString method of the object class returns a string consisting of the class name (the object is an instance of the class), the at marker "@", and an unsigned hexadecimal representation of the hash code of this object.

In other words, the method returns a string whose value is equal to:

GetClass (). GetName () + ' @ ' + integer.tohexstring (hashcode ())

Cases:

1 Student s = new Student (), 2 System.out.println (S.getclass (). GetName ());//com.test.student3 System.out.println ( S.hashcode ());//32034434//Convert a number to hex 5 System.out.println (integer.tohexstring (S.hashcode ()));//30e1736 System.out.println (S.tostring ());//[email protected]7//The name of the direct output object, which is called by default is the ToString () method of the object 8 System.out.println (s); /[email protected]

11.28 equals () method of the object class

public boolean equals (Object obj): Indicates whether another object is "equal" to this object, the address value is compared by default, but the value of the comparison address is not significant, and generic subclasses should override this method

= = of the base type: The comparison is whether the values are equal

= = of the reference type: compares the address values for equality

Cases:

1 Student s1 = new Student ("Xiaoming", 2 Student s2 = new Student ("Xiaoming", 3); Student s3 = S1;4 System.out.println (S1 = s2); /false5 System.out.println (S1 = = S3);//true 6 System.out.println (s1.equals (S2));//false7 System.out.println ( S1.equals (S3));//true

11.29 equals () method code optimization for the object class

Cases:

Overriding the Equals method of the student class

1 Student s1 = new Student ("Xiaoming", 2 Student s2 = new Student ("Xiaoming", 3); Student s3 = S1;4 System.out.println (S1 = s2); /false5 System.out.println (S1 = = S3);//true 6 System.out.println (s1.equals (S2));//true7 System.out.println (s1.equals (S3)); /true

11.30 the Finalize () method and the Clone () method of the object class

1.protected void Finalize ()

Throws Throwable: This method is called by the object's garbage collector when the garbage collector determines that there are no more references to the object.

2.protected Object Clone ()

Throws Clonenotsupportedexception: Creates and returns a copy of this object

Cases:

1 Student s1 = new Student (); 2 S1.setname ("Xiaoming"); 3 S1.setage (25); 4//Clone Student Object 5 Object obj = S1.clone (); 6 Student s2 = (studen T) obj;7 System.out.println (s2.getname () + ":" +s2.getage ());////Xiaoming: 25

The cloned class must implement the Cloneable interface, the Cloneable interface is a markup interface to indicate that the Object.clone () method can legitimately replicate the class instance by field

Javase Learning Summary 11th Day _ Development tools & API Common Objects 1

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.