Java: class1 data types

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_43336822/article/details/93221162

JAVA data types

1.byte: 1 byte
2.long: 8 bytes
3.char: 2 bytes
4.boolean: not discuss the number of bytes, regardless of 0/1, but ture / to false
5. The basic structure: public class TestDemo {
static void main public (String [] args) {
}
}
6. The output: System.out.printf ( "% d", 10) [ not]
System.out.println ( "") [LN Representative ENTER] [the System .out.println ( "Get value is:" + a);]
of System.out.print ( ""); [not ln, the output is not eNTER]
7. input: Scanner scanner = new Scanner (System.in ) ; [reference Scanner: Import java.util.Scanner;]
int = A scanner.nextInt ();
8. The random values: the random random new new = the random ();
int = A random.nextInt (bound: 5000) + 1'd; [ 1,5001) in value, bound is defined by the system, the digital output directly in the brackets, automatic pop-bound]
9.Java can still use ASCII, but actually use the Unicode character set

Type strong turn

          int a=10;
          byte b=a;    //系统报错
强制转换:
          int a=10;
          byte b=(byte)a;

隐式转换:                                                                   [byte 8;int 32;]
          byte a=10;
          int b=a;

Guess you like

Origin blog.csdn.net/qq_43336822/article/details/93221162