JAVA-前

Float.parseFloat();
//转换float类型
Integer.parseInt();
//转换int型
float f = 12.3f;
//float赋值


//输入
import java.util.Scanner;
Scanner sc = new Scanner(System.in);
float yuwen =sc.nextFloat();
String c=sc.next();//输入字符串

double PI = Math.PI;

.equals()//判断字符串相同
.equalsIgnoreCase()//不区分大小写


//软件运行时间
long start = System.currentTimeMillis();
System.out.println(start);
long end = System.currentTimeMillis();
System.out.println(end);


//产生随机数
import java.util.Random;
Random rd = new Random();
int pc = rd.nextInt(100) + 1;//产生1-100之间的随机数
int pc = rd.nextInt(shuzu.length) + 1;//数组大小范围内的随机数
int q = rd.nextInt(max)%(max-min+1) + min;//指定大小随机数

//声明数组
int[] shuzu = new int[4];
int[] shuzu;
for(int i=0;i<shuzu.length;i++)
{
System.out.println("输入数据:");
shuzu[i]=sc.next();
}
System.out.println(shuzu.length);//输出数组长度

Arrays.sort(shuzu);//给数组排序从小到大
//异常处理
try
{
}
catch (Exception e)
{
}

//字符串
String zifu = "qwertyuiop";
String zifu1 = new String("qwertyuiop");//通过构方法创建字符串
char[] zifushuzu = newchar[]{'q','w','e','r','t','y','u','i','o','p'}
String zifu2 = new String(zifushuzu);//使用字符数组创建支付串
zifu.length();//字符串长度
char c = str.charAt(2);//通过字符串下标获取字符串
System.out.println(c);
//判断字符串
boolean f1 = name.startsWith("qwe");//判断字符是否以qwe开头
boolean f2 = name.endsWith("iop");//判断字符是否以iop结束
zifu.equals(qwertyuiop);//判断字符是否相等
zifu.equalsIgnoreCase(qwertyuiop);//忽略大小写,判断字符是否相等
//查找字符串
zifu.indexOf("qwert");//查找字符串是否存在,存在返回0,不存在返回-1;
//返回第一个字符的下标值;
//截取字符串
zifu.substring(开始索引);//开始到结束;
zifu.substring(开始索引,结束索引之前);//从哪到哪;
//替换字符串
zifu.replace(旧的,新的);

.trim();//去掉字符串左右两端的空格;
//字符串的分割(适用于有规律的字符串);
.split("符号");//返回值是一个字符串数组;
String[] zfshuzu = zifu.split(符号);

//-------翻译------------
system//系统
Containers//集装箱
Layouts//布局
Strut Spring//支柱弹簧
Components//组件
Swing Action//挥杆动作
Menu//菜单
AWT Components//AWT组件
JGoodies//JGoodies数据

posted @ 2016-06-23 23:17  生如夏花~  阅读(183)  评论(0)    收藏  举报