
J2SE 复习
文章平均质量分 76
dreamsky1989
这个作者很懒,什么都没留下…
展开
-
复习笔记6 位运算 2进制数据的操作
public class Test7{ public static void main(String[] args) { // & 按位与 //看这行像什么,像逻辑运算符哪里我们写的吧 //0为假,1为真,那么结论就是第四行为1 //而在运算方面,我们可以根据这个规则进行 //逐位运算,即同为1为1,否则为0 System.out.println(0 & 0);原创 2012-05-18 03:48:50 · 605 阅读 · 0 评论 -
复习笔记13 函数 重载 内联
public class Test14{ void method(int arg0, int arg1){} //这种换参数名字的方式并不算重载// void method(int arg1, int arg0){} //参数列表类型的排列组合不一样,可以形成重载 void method(int arg0, byte arg1){} //参数类型位置调换也可以形成重载原创 2012-06-06 04:22:54 · 456 阅读 · 0 评论 -
复习笔记12 作用域标记 以及中断语句
public class Test13{ public static void main(String[] args) { //标记以及中断语句 //java和c++有个小区别,c++中可以使用goto //进行跳转,事实上c++中goto用的比较多的就是 //goto end,而在java中也沿袭了这一传统,就 //是一个阉割版的goto指令 //标记的原创 2012-06-06 03:11:52 · 429 阅读 · 0 评论 -
复习笔记11 循环 以及优化
import java.util.ArrayList;public class Test12{ public static void main(String[] args) { //先判断后执行 int x = 0; while(x < 3) { System.out.println(x++); } System.out.println("=======原创 2012-06-04 02:11:11 · 302 阅读 · 0 评论 -
复习笔记5 位运算符 以及位移超出整数类型边界的回滚原理
public class Test6{ public static void main(String[] args) { //位运算符 // << 左移运算符 //5 的二进制是 0000 0101 //左移一位的话0000 1010 //5 左移一位是10,是不是相当于5*2 System.out.println(5 << 1); //3左移一位正好是6 S原创 2012-05-17 14:36:31 · 490 阅读 · 0 评论 -
复习笔记4 比较运算符
public class Test5{ public static void main(String[] args) { //比较运算符 int x = 5; System.out.println(x > 5); System.out.println(x < 5); System.out.println(x == 5); System.out.println(x !=原创 2012-05-15 06:01:20 · 337 阅读 · 0 评论 -
复习笔记3 算数运算符 转义字符 转义序列 前后自增自减的区别
public class Test4{ public static void main(String[] args) { //算数运算符 int x = 0; x = 1 + 2; x = 2 - 1; x = 2 / 1; x = 2 * 1; //除法并不会保留小数部分,也不会四舍五入 //而是舍弃全部的小数部分 x = 9 / 5; Sys原创 2012-05-14 22:15:03 · 1259 阅读 · 0 评论 -
复习笔记2 变量 类型转换 自动升位
public class Test3{ public static void main(String[] args) { //定义变量,基本类型的取值范围和位长度 byte b = 0; System.out.println((b = Byte.MAX_VALUE)); System.out.println((b = Byte.MIN_VALUE)); System.ou原创 2012-05-10 03:48:49 · 1179 阅读 · 0 评论 -
复习笔记10 switch 编译器优化的两种方式 和if的效率对比
public class Test11{ public static void main(String[] args) { //输出的是0和1,看起来没有问题,不过要是 //0的时候输出a,1的时候输出b呢? for(int i = 0; i < 3; i++) { //根据i的值进行选择输出 switch(i) { case 0: case原创 2012-06-03 23:24:04 · 884 阅读 · 0 评论 -
复习笔记9 if else 以及效率优化
public class Test10{ public static void main(String[] args) { //if else int x = 0; //当表达式x > 1为真时进入作用域1中 //当表达式结果为假时进入作用域2中 //作用域1 和 作用域2是不会并存的 if(x > 1) { // 1 } else {原创 2012-06-03 19:46:21 · 508 阅读 · 0 评论 -
复习笔记8 位映射实现的权限管理
public class Test9{ public static void main(String[] args) { User user = new User(); //这里我们给了用户两个权限,一个注册,一个登陆 //01 | 10 结果是 11,这没什么好说的了,都讲过了 user.setPermission(Permission.BBS_PERMISSION_REG原创 2012-05-20 14:52:44 · 383 阅读 · 0 评论 -
复习笔记1 进制以及进制转换
import java.io.IOException;public class Test2{ public static void main(String[] args) throws IOException { // java 中 10 8 16进制常数的写法 System.out.println(512); System.out.println(01000); S原创 2012-05-04 16:42:15 · 396 阅读 · 0 评论 -
复习笔记7 位映射图
public class Test8{ public static void main(String[] args) {// 1.给定集合A{0,1,2.....30,31}// 2.给定集合B{5,6....10,11}// 3.求 A 和 B 的交集// 4.求 A 和 B 的并集// 5.求 B 相对于 A 的补集// 6.求 A 对 B 差集// 7.求给原创 2012-05-19 01:27:46 · 403 阅读 · 0 评论 -
复习笔记14 数组
import java.util.Arrays;public class Test15{ public static void main(String[] args) { //如果以此种方式创建数组,则必须定义数组长度 int[] arr = new int[3]; //这种方式的创建,不限制长度,以你声明的元素 //个数决定长度 int[] arr$1 =原创 2012-06-06 09:05:56 · 384 阅读 · 0 评论