dart语法-操作符、方法与异常
变量
void main(){
Object a = "Lance";
a = 100; //ok
var j = "lance";
j = 100; //err
var k;
k = "lance"; // ok
k = 100; // ok
dynamic c;
c = 100; //ok
c = "fdsoad"; //ok
final mm = 1;
mm = 2; //error
final int mmm = 1; // when running
mmm = 2; //error
const nn = 1; // when compling , efficency higher
nn = 2 //error
const z = mmm; //error const can not = final
final x = nn; //ok final can = const
}
dart七种数据类型
数据类型 num{double, int}
//dart当中的int, 在编码的时候,可以将int当成java的short int,long来使用
//如果dart代码超过了4个字节,那么dart会将其编译成类似java当中的long
void main(){
int i= 10;
print(i.bitLength);
}
结果是4,因为10转化为二进制占4位
字符串类型 String
List 数组
通过数组一样通过下标取元素
Map
Unicode: Runes: 特殊字符表示类Unicode32