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