Java Basic Grammar Notes

Source: Internet
Author: User

1. Basic Format :

public class Hellowprdapp {

public static void Main (string[] args) {
TODO auto-generated Method Stub
int num = 10;
num = 30;
System.out.println ("num=" +num);
System.out.println ("num*num=" +num*num);
}

}

String args[]: The traditional way of writing, C, C + + all use this kind of notation;
String[] Args:java, but Java can also be defined using the above method.
Actually string[] args is the definition of a string array variable.
In Java, string[] args and String args[] can all define arrays. There's no difference between the two. For specification coding, we recommend using string[] args. In addition, args can be arbitrarily changed, as with other variables, it is just a variable name, as long as the variable name rules can be.

  To print a statement :

System.Out.println (""); With line breaks

System.Out.print (""); No line breaks

Java states that there are two ways to declare a class :

<i>public class name is the same as the name of the file, otherwise it cannot be compiled

The <ii>class class name can be different from the name of the file, and the class name is generated at compile time. class

2.Java basic data type

Data type size/bit can represent the range of data

  Long (length integer) 64-2^63~2^63-1

int (integer) 32-2^31~2^31-1

Short (shorter integer) 16-32768~32767

  BYTE (bit) 8-128~127

char (character) 2 0~255

Float (single precision) 32-3.4e38~3.4e38

Double (dual precision) 64-1.7e308~1.7e308

When the value overflows , a cycle is formed, that is, the maximum value plus 1 will become the minimum value.

Two methods for casting types

integer.max_value+2l add a number followed by an L to represent a casting growth shaping

((long) integer.max_value+2) precede the plus number with a long to implement the cast

3. commonly used escape characters

Escape Character Description

\f Page Change

\ \ Backslash

\b Backwards One lattice

\ ' Single quotation mark

\ r return Position

\ "Double quotation marks

\ t Tab tab

\ nthe line break

  

Java Basic Grammar Notes

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.