Java applet 2 (2015-8-6)

Source: Internet
Author: User

1.

public class DataDemo2 {

public static void Main (String [] args) {

Char c1= ' A ';

Char c2=97;

Char c3= ' \u0041 ';

Char c4=65;

SYSTEM.OUT.PRINTLN (C1);

System.out.println (C2);

System.out.println (C3);

System.out.println (C4);

} }

2.

public class luojitest{

public static void Main (String [] args) {

int num1=20;

int num2=30;

System.out.println ("Short circuit with:" + ((num1>num2) && (num1>10))); System.out.println ((num1>num2) | | (num1>10));

SYSTEM.OUT.PRINTLN (! ( NUM1>NUM2));

System.out.println ((num1>num2) & (NUM1>10));

System.out.println ((num1>num2) | ( NUM1>10));

System.out.println ((num1>num2) ^ (num1>10));

}}

3.

public class weifei{

public static void Main (String [] args) {

int num1=8;

/* Sign bit: 0 for Integer, 1 for negative number

0000 0000 0000 0000 0000 0000 0000 1000

Take reverse: 1111 1111 1111 1111 1111 1111 1111 0111

Get the complement of negative numbers: (sign bit unchanged, others are reversed)

1111 1111 1111 1111 1111 1111 1111 0111

1000 0000 0000 0000 0000 0000 0000 1000

Complement of negative numbers + 1:

1000 0000 0000 0000 0000 0000 0000 1000 + 1

--------------------------------------------------------------------

0000 0000 0000 0000 0000 0000 1001---->-9

*/

System.out.println (to); }}

4.

public class weihuotest{

public static void Main (String [] args) {

int num1=10;

int num2=8;

/* Num1:10

0000 0000 0000 0000 0000 0000 0000 1010

Num2:8

0000 0000 0000 0000 0000 0000 0000 1000

-----------------------------------------------------

0000 0000 0000 0000 0000 0000 0000 1010

0000 0000 0000 0000 0000 0000 0000 1000

-----------------------------------------------------

0000 0000 0000 0000 0000 0000 0000 1010------>10

*/

System.out.println (NUM1|NUM2); }}

5.

public class yihuotest{

public static void Main (String [] args) {

int num1=10;

int num2=8;

/* num1:10 0000 0000 0000 0000 0000 0000 0000 1010

num2:8 0000 0000 0000 0000 0000 0000 0000 1000

-----------------------------------------------------

0000 0000 0000 0000 0000 0000 0000 1010

0000 0000 0000 0000 0000 0000 0000 1000

-----------------------------------------------------

0000 0000 0000 0000 0000 0000 0000 0010------>2

(Arithmetic rule: the "XOR" operation in a bitwise operation, if the two data corresponding bits are 1, then the bit of C is 1, otherwise 0.) ) */

System.out.println (NUM1^NUM2); }}

6.

public class yiwei{

public static void Main (String [] args) {

int num1=8;

/* 0000 0000 0000 0000 0000 0000 0000 1000 Shift Right 2 bit */

System.out.println (NUM1>>2);

System.out.println (NUM1<<2); }}

/*

int num1=-10 Original code-"anti-code-" complement-"shift

1000 0000 0000 0000 0000 0000 0000 1010--Original Code

Find the inverse code: the original code of the symbol bit unchanged, the rest of the reverse

1111 1111 1111 1111 1111 1111 1111 0101--anti-code

The complement is: anti-code +1

1111 1111 1111 1111 1111 1111 1111 0110--complement

After the complement is obtained, the complement is shifted (inverse shift operation) to the right by two bits:

0011 1111 1111 1111 1111 1111 1111 1101--The shift (positive number) is a positive number, which is the original code.

0011 1111 1111 1111 1111 1111 1111 1101---positive source code

*/

Java applet 2 (2015-8-6)

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.