Chapter 3 Introduction to Objects and Input/Output

与声明一个primitive variable不同,声明一个对象的时候,并不创建用来存储一个对象的内存空间,而是创建了一个存储该对象所在内存空间的地址。

在java里,new是一个操作符,它让系统分配一个特定类型的存储空间,并返回该内存空间的地址。

String str;

str = “Java Programing”;

String str = new String("Java Programing");

是有区别的,前者是把已经存在的“Java Programming”的存储地点赋值给str,而后在,需要先生存一个"Java Programing",然后再把它的地址赋值给str。

In reality, when the statement in Line 4 executes, it first looks if the program
has already created the string "Java Programming". If this is the case, then the
String variable str will point to that memory location. However, when the statement
in Line 5 executes, the system will allocate a memory space, store the string "Java
Programming" into that memory space, and then store the address of that memory
space into str. This is a key difference and plays an important role when strings and
String variables are compared, which we will explain in Chapter 4.

In Java, variables such as str are called reference variables. More formally, reference
variables are variables that store the address of a memory space. In Java, any variable
declared using a class (such as the variable str) is a reference variable. Because str is a
reference variable declared using the class String, we say that str is a reference
variable of the String type.

Primitive type variables store data directly into their own memory spaces. Reference
variables store the address of the object containing the data. An object is an instance of
a class and the operator new is used to instantiate an object. In some languages, such as
C++, reference variables are called pointers.
Before discussing the class String, we first discuss how to use predefined methods in a
program.

There are two types of methods in a class: static and non-static. A static
method can be used, that is, called, using the name of the class containing the method.
static修饰的method,可以直接用类名来调用它,比如Math.pow(2,3)。

129页,输入输出

时间: 2024-11-03 15:02:29

Chapter 3 Introduction to Objects and Input/Output的相关文章

TIJ英文原版书籍阅读之旅——Chapter One:Introduction to Objects

///:~容我对这个系列美其名曰“读书笔记”,其实shi在练习英文哈:-) Introduction to Objects Object-oriented programming(OOP) is part of this movement toward using the computer as an expressive medium. This chapter will introduce you to the basic concepts of OOP, including an over

Chapter 4 Character Strings and Formatted Input/Output

Null Character:\0 # define TAXRATE 0.015       //when your program is compiled,the value 0.015 will be substituted everywhere you have used TAXRATE.this is called a compile-time substitution. const int MONTHS =12;         //MONTHS a symbolic constant

数据库服务器Input/output error (故障20170122)

描述: 数据库系统出现告警,登陆查看使用系统命令报错,提示Input/output error 模拟故障处理过程: 检查文件系统时,该文件系统必须卸载.当出现错误时fsck会提示是否修复, 可以用-y参数:不提示是否修复 fsck - check and repair a Linux file system # df -h Filesystem            Size  Used Avail Use% Mounted on /dev/mapper/vg_mysql80-lv_root 2

解决NGINX+PHP-FPM failed to ptrace(PEEKDATA) Input/output error出错问题

网站总是出现bad gateway 提示,时有,时无,查看了一下日志,居然出现一堆错误,如下 [29-Mar-2014 22:40:10] ERROR: failed to ptrace(PEEKDATA) pid 4276: Input/output error (5) [29-Mar-2014 22:53:54] ERROR: failed to ptrace(PEEKDATA) pid 4319: Input/output error (5) [29-Mar-2014 22:56:30]

解决ubuntu挂载NTFS磁盘时出现input/output error

错误内容如下: Error mounting: mount exited with exit code 13: ntfs_attr_pread_i: ntfs_pread failed: Input/output error Failed to read NTFS $Bitmap: Input/output error NTFS is either inconsistent, or there is a hardware fault, or it's a SoftRAID/FakeRAID ha

Input/output subsystem having an integrated advanced programmable interrupt controller for use in a personal computer

A computer system is described having one or more host processors, a host chipset and an input/output (I/O) subsystem. The host processors are connected to the host chipset by a host bus. The host chipset is connected to the input/output subsystem by

黑马程序员——java基础---IO(input output)流字符流

黑马程序员——java基础---IO(input output)流字符流 ------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------- io(input output)流特点: 1,io流用来处理数据之间的传输 2,java对数据的操作是通过流的方式: 3,java用于操作流的对象都在io包中: 4,流按操作数据分为两种:字节流和字符流: 5,流按流向分为:输入流和输出流. 注意:流只能操作数据,而不能操作文件. 3.IO流的常用基类: 1)字节流的抽象

html5 填表 表单 input output 与表单验证

1.<output>     Js计算结果 <form oninput="res.value = num1.valueAsNumber*num2.valueAsNumber"> <input type="number" id="num1"> X            <!-- 没有闭合</input> --> <input type="number" id=&q

Linux下“read failed after 0 of 4096 at 0: Input/output error”

1.故障描述( 在线移除一块被设置为pv格式的硬盘,提示unknown device报道):/dev/sdb1 /dev/sdc1 /dev/sdd1是组成/dev/vg_test/lvm_test的PV,这里我们模拟/dev/sdd1硬盘被直接断电了 [[email protected] mnt]# pvdisplay    /dev/sdd: read failed after 0 of 4096 at 0: Input/output error   /dev/sdd: read faile