Try to edit a Java program

Source: Internet
Author: User

Trying to compile a Java program

Before using software eclipse compiled a simple Hello Java program, because the software operation is simple, and later learned to use the command character to compile the program. The code is as follows

public class ABC

{
public static void Main (string[] args)
{
System.out.println ("Hello java! ");
}

}

Then use the debug command to jump to the folder to compile successfully

Later read the book on the bit operations related knowledge, respectively is &and, |or, ^xor, ~ complement. The format control symbol%d is output in decimal integer format and can be used with byte, short, int, long, and so on. Compile according to the knowledge in the book, the code is as follows. function System.out.ptintln (""); you can output many characters in a format, or you can mix output, but printf cannot.

Package java2;

public class HH {
public static void Main (string[] args)
{
System.out.println ("and Operation:");
System.out.printf ("0 and 0%5d%n", 0 & 1);
System.out.printf ("0 and 1%5d%n", 0 & 1);
System.out.printf ("1 and 0%5d%n", 1 & 0);
System.out.printf ("1 and 1%5d%n", 1 & 1);

System.out.println ("\nor operation:");
System.out.printf ("0 OR 0%6d%n", 0 | 1);
System.out.printf ("0 OR 1%6d%n", 0 | 1);
System.out.printf ("1 OR 0%6d%n", 1 | 0);
System.out.printf ("1 OR 1%6d%n", 1 | 1);

System.out.println ("\nxop operation:");
System.out.printf ("0 XOR 0%5d%n", 1 ^ 1);
System.out.printf ("0 XOR 1%5d%n", 1 ^ 1);
System.out.printf ("1 XOR 0%5d%n", 1 ^ 1);
System.out.printf ("1 XOR 1%5d%n", 1 ^ 1);

}

}

However, when the command is compiled, the first line of the package java2 need to be deleted before it can be compiled (but not very clear principle)

Try to edit a Java program

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