==keywords
1. goto and const are keywords but have no meaning
2. assert was introduce by JDK1.4
3. enum was introduced by JDK1.5
==variable types
byte : 1 byte (signed -128~127): (byte)0
short : 2 bytes : (short)0
int : 4 bytes: 0
long : 8 bytes: 0L
float : 4 bytes: 0.0f
double: 8 bytes: 0.0d
char : 2 bytes ( unsigned): ?
boolean: : false
class
interface
array
==conversion rule
1. short length varible to long length variable: conversion is automatic longa = inta
2. long length variable to short length variable: must manually convert by inta = (int) longa;
3. byte->short->int->long->float->double;
3. constant is by default int and double. so we have to use
int a = 30;
long a = 30;
long a = 30L;
long a = 30l;
double a = 33.333;
float a = (float) 33.333;
float a = 33.333f;
==char type
1. char is 16 bit variable, and in Java,all char is unicode, so a char can hold a chinese char
char a='你';
int xa=a;
==boolean
1. Only allow "true" or "false".
2. Not allow 0 for false, and non-zero for true;
==String
1. it is a class because its first letter is capital letter
2. it can used as intrinsic type variable
3. every type convert to String if there is a String in the expression
String str="";
System.out.println(str+10+20) => 1020
System.out.println(str+(10+20)) => 30
没有评论:
发表评论