摘要:1.
阅读全文
文章分类 - 【4】【Java】
摘要: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
阅读全文
摘要:一组相关的字符可以用string来表示在Java中,是用内置的类来实现的,这个类置的类是StringString不是简单的字符的数组其中没有终止字符’\0’ 3. 创建并初始化一个String 的对象
阅读全文
摘要:public class Aaa{ public static void main(String[] args){System.out.print("执行偶吧!"); } }保存为:Aaa.java编译:在开始--运行--输入:cmd输入:cd 指定你保存文件的文件夹路径--dir找到这个文件开始输入:javac Aaa.java运行:java Aaa
阅读全文
摘要:一、Retail Application – Case Studyclass Customer{ private int customerId; private long telephoneNo; public void setCustomerId(int customerId){ customerId = customerId; } public int getCustomerId(){ return customerId; }}class Retail{public static void main(String args[]){ Customer custObj = new Custom
阅读全文
摘要:1.Whenever an object is created , memory wil be allocated for the instance variables also.They will be stored in the heap memory along with the object to which they belong2.Note :Here it is assumed that reference variable declaration is done inside the main() method,hence will be treated as a local
阅读全文
摘要:1.Java Programming Language2.Java Byte Code3.Java Virtual Machine1.Java Program(.java)2.Java Compiler(javac)3.ByteCode(.class)4.Interpreter5.Win32、Linux、Mac
阅读全文
摘要:1.Customer classsclass Customer{ private int customerId; private long telephoneNo; public void setCustomerId(int id){ cutomerId=id; } public void setTelephoneNo(long teleNo){ telephoneNo=teleNo; } public int getCustomerId(){ return customerId; } public long getTelephoneNo(){ return telephoneNo; }}2.
阅读全文
摘要:1.在编辑器中写下代码2.保存文件3.编译程序4.执行代码
阅读全文
摘要:1.类是创建一个对象的蓝图2.要实现一个类,就要创建一个对象3.对象是类的实例4.一个类可以有很多实例,每个实例可以有自己的数据5.运算符new用来在运行时动态的为对象分配内存(dynamic memory allocation)6.创建一个对象时会为对象生成一个引用(参考、参照),为对象新创建的引用必须赋值个一个变量,这个变量被称作引用变量;可以给引用变量赋值null,这样不指向任何对象。
阅读全文
摘要:1.标示符的规范化2.变量3.数据类型4.方法5.访问控制符6.用JAVA来实现一个类
阅读全文

浙公网安备 33010602011771号