个人说明大全,java.doc
文本预览下载声明
个人说明大全,java
篇一:java常用语句大全
1.
2. (根据老师讲得内容,自己总结的) Random r=new Random(); int i=r.nextInt(); 产生
随机数
3. Scanner in = new Scanner(System.in);int n = in.nextInt(); 控
制台输入
4. System.out.println(Integer.toBinaryString(-12)); 二进
制转换 32位
5. System.out.println(Long.toBinaryString(12)); 二进
制转换 64位
6. System.out.println(Integer.toHexString(46)); 十六
进制转换
7.
8. Math.sqrt 开根号 条件? 条件成立:条件不成立 三目运
算
9. switch(score/10){case 10:case 9:level=quot;优秀
quot;;break; switch.case 语句演示
10. 循环条件(布尔表达式){循环体} while
循环
11.
12. while(true) 和 for(;;) 等价 for(;;) do{ 循环体1} while(循环条件2) 1--2--true--1--2--false--结
束 do..while
13. int[]ary4={4,5,6}; int[]ary=new int[]{4,5,6}; 数组的
三种写法
14.
15.int[] ary=new int[length]System.out.println(Arrays.equals(arr1, arr2)); //布尔类型 数
组比较
16.
17.
18. Arrays.sort(balls);数组排序 //(原数组,原数组位置,目标数组,目标数组位置,个数) System.arraycopy(ary1, 0, ary4, 0, ary1.length); 数组
复制
19. balls=Arrays.copyOf(balls,balls.length+1); 复制数
组
20.
21.
22.
23.
24. Cell[] cells = new Cell[] { new Cell(0, 4), new Cell(0, 3), new Cell(0, 5), new Cell(1, 4), }; 二维数组 Cell[][]wall=new Cell[20][10];Timer timer=new Timer();, timer.schedule(new MyTask(),
0,1000);//1000ms=1s 定时器
25.
26. 被执行的任务 第一次执行延时时间 时间间隔 System.out.println(quot;同一个对象:quot; + (p1 == p2));比
较是否同一个对象
27. System.out.println(quot;内容一样:quot; +
(p1.equals(p2))); 比较内容是否一样
28. String lower=str.toLowerCase();将字符串
转换为小写
29. String upper=str.toUpperCase();将字符串
转换为大写
30. String trim=str.trim(); 去掉字符串两
边空白
31. boolean starts=str.startsWith(quot;Helquot;);boolean类
型是以Hel开头
32. boolean ends = str.trim().endsWith(quot;orldquot;);去掉空
白,orld结尾
33. int index = str.indexOf(quot;inquot;); 获取字符位
置
34. index = str.indexOf(quot;inquot;,5);从str第6个字符开始
检索第一次出现in的位置
35. int last = str.lastIndexOf(quot;inquot;);从str中检索最
后一次出现in的位置
36. char chr = str.charAt(5); 获取字符串
中指定位置的字符
37. String[] array=str.split(quot;\\squot;); 以空格进行
拆分数组
38. int a=Integer.parseInt(array[0]); 将拆分的
字符串转换为数字
39. byte[] d
显示全部