java基础总结

float 赋值时后边加f  如 float ff=1.2f;

静态变量 声明时前边 + static   如static int x=0;

数据类型转换 低精度可以直接转换成高精度,高精度转换成低精度 需要显示类型转换

int x=50;

float y=x;

显示转换

int a=(int) 45.23;

foreach 语句

int str[]=new int[5];
for(int x:str)
System.out.println(x);

字符串;

判断字符串是否相等可以直接 用  str.equal(st);

比较函数为 compareTo();

字符串截取函数 substring(1,3);

查找函数

String str="1234567";
for(int i=0;i<10;i++)
{
char mychar=str.charAt(i);
if(mychar=='2')
;
}

正则表达式 方法  http://wenku.baidu.com/view/2695644de45c3b3566ec8b07.html

字符串生成器

StringBuilder builder=new StringBuilder("");
for(int i=0;i<10;i++)
builder.append(i);
System.out.println(builder);

数组

填充:

int str[]=new int[5];
Arrays.fill(str,1);
for(int i=0;i<5;i++)
System.out.println(str[i]);

排序为

Arrays.sort(arr);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值