1. Automatic type conversion
Automatic type conversions, also known as implicit conversions, can convert an int variable to a float type.
1 Public classConver {2 Public Static voidMain (string[] args) {3 4 byteMyByte = 127;5 intMyint = 150; 6 floatMyfloat = 452.12f; 7 CharMyChar = 10; 8 DoubleMyDouble = 45.46546; 9System.out.println ("byte-type and float-type data is calculated as:" + (MyByte +myfloat));Ten /*outputs the result of the Operation*/ OneSystem.out.println ("byte type and int type data are calculated as:" + MyByte *Myint); ASystem.out.println ("Byte-type and char-type data is calculated as:" + MyByte/MyChar); - System.out -. println ("Double-type and char-type data results in:" + (MyDouble +MyChar)); the } -}
2. Forcing type conversions
Coercion type conversions are also known as explicit type conversions.
Convert different data types.
The syntax format is as follows: (type name) the value to convert
int a = (int) 23.23; long y = (long) 234.34; int b = (int) ' d ';
3. Code comments
Comments are for people, not for computers.
Java annotations are divided into three types;
1, single-line comment; 2, multiline comment; 3. Document comment.
1. Single-line Comment
As a single-line comment marker, everything from the symbol "//" until the line breaks is ignored as comments.
The format is as follows://comment Content
int age;//define int variable for saving ages
2, multi-line Comment
/* */For multiline comment markers. /* and/* must appear in pairs.
The syntax format is as follows:
/*
#¥%......&
%#%............
/*
3. Documentation Comments
/** * * marks the document comment.
The contents of the symbol/** * * are treated as Javadoc documents by Java.
Java Language Basics-type conversion