byte /Byte
short /Short
int /Integer
long /Long
float /Float
double /Double
char /Character
boolean /Boolean
Integer: class that encapsulates the basic int type
Attribute :
int Maximum value: Integer.MAX_VALUE
Minimum value of int: Integer.MIN_VALUE
method:
Convert an integer to a string: Integer.toString(100);
Convert an integer to a string of the corresponding base: Integer.toString(100,2);
Convert a pure number string to an integer: Integer.valueOf("12345");
Integer.valueOf("1100011",2);
Convert a pure number string to an integer: Integer.paserInt("12345");
Integer.paserInt ("1100011",2);
Case:
1. Convert the integer 97 to binary, octal, hexadecimal
2. Convert binary to decimal
-------------------------------------------------- -------------------
Math class:
property: E
PI
method: Math.abs(t);
Math.max(a,b);
Math.min(a, b);
Math.pow(a,b);
Math.sqrt(a);
Math.random();
------------------------- ---------------------------------------------
System class
System.err .println();
System.out.println();
System.in
exits the program normally: System.exit(0);
// The current system time, calculated from 1970-01-01 00:00:00:0000 to the present Elapsed milliseconds
long t = System.currentTimeMillis();
int[] a = { 1, 2, 3, 4, 5 };
int[] b = new int[10];
//copy the array
System.arraycopy( a, 1, b, 4, 3);
parameter 1: source array
Parameter 2: The starting subscript position in the source array
Parameter 3: The target array
Parameter 4: The starting subscript position in the target data
Parameter 5: The number of copies to be copied
------------- -------------------------------------------------- -------
String class:
String
character set standard: which bytes are a character composed of, there are multiple sets of different standards
ISO-8859 Western European character set, excluding full-width characters
GB2312/GBK Simplified Chinese character set
Big5 Traditional Chinese character set
UTF-8 Unicode-based character set
ANSI indicates that the local default character set standard is used.
Construction method
String(byte[] bytes)
String(byte[] bytes,"character set code")
String(byte[] bytes ,start,length)
String(char[] c)
String(char[] c,start,length)
method:
convert the string into a byte array byte[] bs = s.getBytes(); convert
the string according to the specified character set into byte array byte[] bs = s.getBytes("UTF-8");
Convert the string to a character array char[] c = s.toCharArray();
Copy some characters in the string to the character array "ABCDEFG".getChars(1,4,char[],3);
Get the specified position Character char c = s.charAt(subscript);
compares two strings lexicographically compareTo(String anotherString)
compares two strings lexicographically, regardless of case compareToIgnoreCase(String str)
judges whether the string contains Another string contains(CharSequence s)
judges whether the string ends with a suffix endWith(String s);
judges whether the string starts with a prefix startWidth(String s);
judges whether two strings are equal equals( String s)
judge whether two strings are equal, ignoring case equalsIgnoreCase(String s);
judge the position of the first occurrence of the substring in the big string s.indexOf(S1);
judge the substring in the big string The position of the last occurrence in s.lastIndexOf(S1);
get the character length of the string int len = s.length();
Replace string s.replace("old","new");
Intercept string s.substring(startIndex);
s.substring(startIndex,endIndex) ; Convert
all to lowercase characters toLowerCase() ; Convert
all to uppercase characters toUpperCase ();
Remove the blank characters at the beginning and end of the string trim();
Convert other types of data into string type String.valueOf(any type);
Cut the string s.splite(",");
import java.util.Scanner; public class demo { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Please enter a string: "); String str = sc.nextLine(); System.out.println(str); String[] s = str.split(" "); for(int i=0;i<s.length;i++){ System.out.println(s[i]); } } }