2017/05/07 java 基础 随笔

1.^异或  逻辑运算符  两边相同为false  不同为ture

2.键盘录入

package com.huawei;
/**
 * 键盘录入
 * @author Eric
 *
 */
import java.util.Scanner;
public class Demo1 {

    public static void main(String[] args) {
        System.out.println("请输入一个整数");
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        System.out.println(x);
    }

}

3.switch 语句可以接受的表达式

 1)byte short  char int

 2)枚举、字符串

 

4.switch语句,case可以省略吗?

 不可以,case穿透(皇上翻牌子,执行两个^_^)

2017/05/07 java 基础 随笔

 5.switch结束两种情况  break,}

package com.huawei;
/**
 * switch结束break,或者}
 * @author Eric
 *
 */
public class Demo3 {

	public static void main(String[] args) {
		int a=2,y=3;
		switch (a) {
		default:
			y++;
		case 2:
			y++;
		case 4:
			y++;
			break;
		}
		System.out.println("y="+y);
	}

}

 6.while 和for的区别

  for语句执行完,变量会被释放,while执行后,初始化变量还可以使用

7.转义字符

\ " ——— "

\'  ——— '

\t  ———tab键

\r  ———回车

\n  ———换行

8.break只能使用在switch和循环中

9.continue只能使用在循环中

10.标号

下面的代码没有问题

 2017/05/07 java 基础 随笔

 

11.重载

方法名相同,参数列表不同,与返回值类型无关;

posted @ 2017-05-07 16:07 酸奶加绿茶 阅读(...) 评论(...) 编辑 收藏

相关文章: