初识JAVA

  • 常量
    • 定义:永远不变的量就是常量,其值不能改变,不随时间变化的某些量和信息。常量也称为直接量。
    • java支持8种类型的直接量,int/long/float/double/boolean/char/String/null。
  • 变量
    • 在程序运行过程中,空间内的值是变化的。这个内存空间就是变量。
    • 声明一个变量的格式:  type  varName  value
    • 局部变量:在一个方法块或者一个函数内起作用。
    • 全局变量:比局部变量作用域更大。
    • public class Main{
      byte x;
      short y;
      int z;
      long a;
      float b;
      public static void main(String[] args){
      int z=111;
      System.out.println("print " + z);
      }
      }
原文地址:https://www.cnblogs.com/mascot1/p/10093599.html