Java Basics-fourth day jobs

Source: Internet
Author: User
Tags xms

1. Sort the bitwise operations, especially the left and right shifts (with or without symbols) to your blog.

The emphasis is on the operation process of clear negative numbers.

2.byte to hexadecimal string representation programming principles and implementation methods are organized into blogs.

3. Define a function to calculate the and of all elements of an integer array.

4. Copy of the array.

5. Heap memory default is 1/4,


JAVA-XMX//Set heap memory max

-XMS//Set heap memory initial value

ClassName//class name


Bit arithmetic

A = 3; B =-3

Binary form +3:0000 0011 take counter plus one -3:1111 1101

Signed move: A<<2 to the left two-bit 0000 11,000 binary is a b<<2 to the left two bits 1111 1000 binary Yes-12

A>>2 move right two bit 0000 0 binary Yes 0 b>>2 move right two bit 1111 11,110 binary Yes -1

Unsigned move: A<<<2 to the left two-bit 0000 11,000 binary is a b<<<2 left move two bits 1111 1000 binary Yes 12

A>>>2 move right two bit 0000 0 binary Yes 0 b>>>2 move right two bit 0011 11,110 binary Yes 63



* Byte Turn hex

* Hex each 0-f binary 4 bits so the byte is divided into two paragraphs, respectively, and 0000 1111 and &, the resulting value is hexadecimal number, the high position to the right four bit as low as the operation, and defines a hexadecimal character array, Let the high-status integer take the hexadecimal corresponding character as an array subscript and derive the return value. (Note that the return value is a concatenation string, and the return value type is string)


Class byte2hexade{

public static void Main (string[] args) {

BYTE b=110;

System.out.print (Byte2hexade (b));


public static String Byte2hexade (Byte B1) {

int low =B1 & 0x0f;

int hig = (b1>>4) &0x0f;

char[] c=new char[]{' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' A ', ' B ', ' C ', ' D ', ' E ', ' F '};

Return ("+c[hig" + c[low]+ "");




Class sumdemo{

public static void Main (string[] args) {

SUM (new int[]{1,3,5,7});


public static void sum (int[] arr) {

int sum=0;

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







Class copyarray{

public static void Main (string[] args) {

Print (Copy (new int[]{2,4,6,8,10}));


public static int[] Copy (int[] arr) {

Int[] Arry=new int[arr.length];

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



return arry;


public static void print (int[] arr) {

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

System.out.print (arr[i]+ "");




5. The default maximum space for heap memory is 1/4 of physical memory, and when running a Java program, you can set the maximum heap memory size by-xms The initial heap memory size-xmx;

This article is from the "Jobs" blog, so be sure to keep this source

Java Basics-fourth day jobs

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: 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.