摘要:
1.当一个变量对于类的对象来说是共同的,这个时候需要使用一个概念:static2.用到的关键字是”static”3.在Java中,static关键字被用在三种场景用于实例变量用于方法用于一段代码4.Static Variables5.Static Methods6.Static BlockRetail Application – Case Studyclass Customer{ private int customerId = 1000; public Customer(){ customerId++; } public int getCustomerId(){ return custome 阅读全文
摘要:
构造函数是一种特殊的方法,和class有相同的名字构造函数是用来初始化类的实例变量的构造函数有两种类型:默认的构造函数和参数化的构造函数ØConstructor is a special method that has the same name as that of a class ØThe constructor is used to initialize the instance variables of the class ØTypes of constructors:§Default constructor§Parameterized 阅读全文
摘要:
public class Aaa{ public static void main(String[] args){System.out.print("执行偶吧!"); } }保存为:Aaa.java编译:在开始--运行--输入:cmd输入:cd 指定你保存文件的文件夹路径--dir找到这个文件开始输入:javac Aaa.java运行:java Aaa 阅读全文