zoukankan      html  css  js  c++  java
  • 17

    第七题:
    找出下列代码中出错的地方,并将其改正.
    public class Test01 {
    public static void main(String[] args) {
    int a; //int a = 0;
    System.out.println(a); //a没有没赋值直接使用
    {
    int c = 20;
    System.out.println(c);
    }
    c = 30; //c取不到值 int c = 30;
    System.out.println(c); //c取不到值
    }
    }

    public class Test02 {
    public static void main(String[] args) {
    byte b = 3;
    b = b + 4; //b需要强转 b = (byte)(b+4); b+=4;
    System.out.println("b=" + b);
    }
    }
    public class Test07 {
    public static void main(String[] args) {
    int x = 2;
    {
    int y = 6;
    System.out.println("x is " + x);
    System.out.println("y is " + y);
    }
    y = x; //y取不到值 int y = x;
    System.out.println("x is " + x);
    }
    }

  • 相关阅读:
    求最低价格
    A*算法入门
    hdu 4715
    手动扩大栈内存,让AC无忧
    hdu 4710
    hdu 1698
    poj3468区间延迟更新模板题
    hdu 1059二进制优化背包问题
    2059龟兔赛跑
    水1276
  • 原文地址:https://www.cnblogs.com/yinjiaxin/p/14215852.html
Copyright © 2011-2022 走看看