Java Step1: Basic knowledge 1

Source: Internet
Author: User

1.string[] Args

Args[i].charat (j): Indicates that the expression will extract the first J characters from the I command-line arguments.

2.ArrayList objects

ArrayList are similar to arrays, but ArrayList can be extended to any size. (in the Java.util package)

Create Arraylist:arraylist table=new ArrayList ();

add element: Table.add (...);

3. Calculate the big factorial 20! is the maximum factorial that a 64-bit integer can hold

The Java.math.BigInteger class represents any large integer, BigInteger is an object rather than a base value, and you cannot simply use the * operator to complete the multiplication of BigInteger objects, you should use the multiply () method.

e.g. for (int size=table.size (); size<=x;size++)

{

BigInteger lastfact= (BigInteger) table.get (size-1);

BigInteger nextfact=lastfact.multiply (biginteger.valueof (size));

Table.add (nextfact);
}

4.integer.parseint (): Converts a string that is drawn to a number

The ReadLine () method of the 5.BufferedReader object implements the technique of reading user input from the keyboard

BufferedReader in=new BufferedReader (New InputStreamReader (system.in));

for (;;)

{

System.out.print (">");

String Line=in.readline ();

if ((line==null) | | | Line.equals ("quit")) break;

}

The string class representing strings in 6.java is immutable. That is, no method is provided to allow the content of the string to be modified. The method for string manipulation returns a new string, not a modified copy of the original string. To manipulate a string in place, you use the StringBuffer object.

String Line=in.readline ();

StringBuffer buf=new StringBuffer (line);

for (int i=0;i<buf.length;i++)

Buf.setcharat (I,buf.charat (i)-1);

    

Java Step1: Basic knowledge 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.