Learning content:
1, mainly for the first 3 days of the Java Foundation exercises, in addition
Representation of numbers in Java
1. decimal int x = 100;
2. Eight binary int y = 077;
3.16 binary int z = 0XEF;
No binary representation
2, bit operation is directly to the binary operation
<< left shift: Removed high-level discard, vacancy 0, equivalent to multiply by 2, the number of times to shift a few by 2;
>> right Shift: removed low drop discarded, the highest bit according to the original symbol to fill, the remaining 0, equivalent to divided by 2 multiples;
>>> unsigned Right Shift: the removed low drop discarded, the vacant bit all fill 0;
3. Byte count to hexadecimal string representation design principle and implementation method
Idea: the B and hex number 0x0f do & operations get a low four-bit value. Then move B to the right 4 bits, again and 0x0f do & operation to obtain a high four-bit value.
Constructs a character array, and the corresponding character can be obtained by subscript.
Conversion functions
public static String Convert2hex (Byte b) {
1. Remove the low four-bit value of byte b
int low = B & 0x0F; Low four bit 0-15
2. Remove the high four-bit value, first move B to the right 4-bit
int high = (b >> 4) & 0x0F; High four-bit 0-15
Defining character arrays
Char[] arr = {' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' A ', ' B ', ' C ', ' D ', ' E ', ' F '};
Splicing string
Return "" + Arr[high] + Arr[low];
}
4, define the function, the calculation of an integer array of all elements and
Computes the sum of an array
public static int sum (int[] arr) {
int sum = 0;
Loop array
for (int i = 0; i < arr.length; i + +) {
Accumulation
sum = sum + arr[i];
}
return sum;
}
5, copy of the array
private static void Copyarr (int[] arr1, int[] arr2) {
for (int i = 0; i < arr1.length; i++) {
Arr2[i] = Arr1[i];
}
}
6, by default, the JVM memory is 1/4 physical memory
Often see Java process ID used: JPS
View heap memory information for a specified Java process using: Jmap-heap PID
When you run the Java program, set the Java heap memory parameters:
JAVA-XMX1G//Set maximum heap memory
-XMS1G//Set initial heap size
classname//class Name
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang /zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
Problems encountered:
Questions to help:
Java Basics-Day 4th