Jerry Education 8

Source: Internet
Author: User

String s= "I Love you China";

Char[] Str=s.tochararray ();

Converts s into a character array.

Stringbuffer:string enhanced version.

StringBuffer statement:

StringBuffer sb=new StringBuffer ();//Create an empty StringBuffer object

StringBuffer sb=new StringBuffer ("AAA");//Create a variable storage AAA

Use of StringBuffer:

Sb.tostring ();//Convert to String type

Sb.append ("* *");//Append string

Use the length () and insert () of the StringBuffer class to implement the requirements.

Sb.reverse (); Implements the reversal (reversal) of the string.

Sb.delete (Start,end); Implements the deletion of strings (starting and ending positions).

Sb.replace (Start,end,replace); implements the substitution of the string, the start and end positions, and replace as the replacement content.

StringBuffer sb3=new stringbuffer ("ABCDEFG");

Sb3.replace (0, 3, "1111");

System. out. println (SB3);

The Replace method in string:

String s= "AAABBBCCCDDDEEEFFFGGG";

String S4=s.replace ("A", "1");

System. out. println (S4);

Steps:

① the Build object. StringBuffer sb=new StringBuffer ();

② assigns a value to an object (adds a string).

③ data processing.

④ used, set length=0. Sb.setlength (0);

Advantages of StringBuffer: Memory savings, more methods than string.

Basic type à packing class (packing)

ValueOf

Example: Byte bytevalue= byte. ValueOf ("21");

Packing class à basic type (unpacking)

Xxxvalue ()

Example: Integer integerid=new integer (25);

int intid= integerid.intvalue ();

int I=integer.parseint ("123"), the ability to convert a string into a basic data type.

The meaning of packaging class lies in object-oriented thinking.

"Classes and Objects"

Classes are summed up and abstracted from objects.

A class is a collection of a set of objects that have the same properties and methods.

The process of object-oriented design and abstraction

Describe a design with a class diagram

The process of design

① Discovery Class

② discovering the properties of a class

③ Methods for discovering classes

④ Optimization Design

The principle of abstraction

① the properties that the system is concerned about

The ② system focuses on methods

Use class diagrams to describe classes: for analysis and design classes, intuitive, easy to understand, tools for Office Visio.

The plus sign in the class diagram represents public, and the minus sign represents private.

Encapsulation Definition: Hides some information of a class inside a class, does not allow external programs to access directly, but through the method provided by the class to implement the operation and access to the hidden information.

Steps for encapsulation:

The property is privatized (private), then the get and set methods are set and then called in the test class.

Encapsulation Benefits: Hidden class Implementation details, easy to join control statements, easy to modify the implementation, only through the prescribed method to access data.

One of the three main characteristics of object-oriented: encapsulation.

The role of construction: allocating memory space to produce objects. Initialization The default construct.

Method overloading: Refers to multiple methods in the same class (method names are the same, parameter lists differ).

Constructor overloads.

Jerry Education 8

Related Article

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.