Common classes and methods of Java

Source: Internet
Author: User

Below we introduce common methods of common classes and classes provided by Java class Library

First, java.lang.String

1. Constructors common to the string class

Public String(string original)

Create a String object using the String object original, where original can be a string constant or a string object

Public String (char value[])

Create a String object using the character array value

Public String (char value[],int offset,int count)

Creates a string object with count characters starting with the character array value subscript as offset

Public String (stringbuffer buffer)

Create a String object using the object buffer of the StringBuffer class

Our upper and lower code:

1  Packagecom.learn.chap04.sec05;2 3  Public classString1 {4      Public Static voidMain (string[] args) {5String S1 =new String ("ASCD");6String s2 =new String (S1);7         8         Char[] Value =New Char[]{' A ', ' B ', ' C '};9String s3 =new String (value);   //copy entire arrayTenString S4 =new String (value,1,2); //Create the string "BC" One System.out.println (S1); A System.out.println (S2); - System.out.println (S3); - System.out.println (S4); the     } -}

Operation Result:

Ascd
Ascd
Abc
Bc

Common classes and methods of Java

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.