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页,输入输出
Chapter 3 Introduction to Objects and Input/Output的更多相关文章
- TIJ——Chapter One:Introduction to Objects
///:~容我对这个系列美其名曰"读书笔记",其实shi在练习英文哈:-) Introduction to Objects Object-oriented programming( ...
- PRML Chapter 1. Introduction
PRML Chapter 1. Introduction 为了防止忘记,要把每章的重要内容都记下来,从第一章开始 2012@3@28 今天又回去稍微翻了一下第一章内容,发现第一次看的时候没有看透,每次 ...
- PHP-FPM-failed to ptrace(PEEKDATA) pid 123: Input/output error
If you're running PHP-FPM you can see these kind of errors in your PHP-FPM logs. $ tail -f php-fpm.l ...
- NFS挂载异常 mount.nfs: Input/output error
[root@localhost ~]# vi /etc/exports #增加/nfs 192.168.10.132(rw,no_root_squash,no_all_squash,async) [r ...
- BIOS(Basic Input/Output System)是基本输入输出系统的简称
BIOS(Basic Input/Output System)是基本输入输出系统的简称 介绍 操作系统老师说,平时面试学生或者毕业答辩的时候他都会问这个问题,可见这个问题对于计算机专业的学生来说是如此 ...
- read()、write()返回 Input/output error, Device or resource busy解决
遇到的问题,通过I2C总线读.写(read.write)fs8816加密芯片,报错如下: read str failed,error= Input/output error! write str fa ...
- Angular 个人深究(三)【由Input&Output引起的】
Angular 个人深究(三)[由Input&Output引起的] 注:最近项目在做别的事情,angular学习停滞了 1.Angular 中 @Input与@Output的使用 //test ...
- Docker 在转发端口时的这个错误Error starting userland proxy: mkdir /port/tcp:0.0.0.0:3306:tcp:172.17.0.2:3306: input/output error.
from:https://www.v2ex.com/amp/t/463719 系统环境是 Windows 10 Pro,Docker 版本 18.03.1-ce,电脑开机之后第一次运行 docker ...
- dpdk EAL: Error reading from file descriptor 23: Input/output error
执行test程序时输出: EAL: Error reading from file descriptor 23: Input/output error 原因: 在虚拟机添加的网卡,dpdk不支持导致的 ...
随机推荐
- 测试框架httpclent 2.配置优化方法
优化就是为了使代码看起来更简便,如果代码里面的每一个请求都写一次url,那么整体代码看起来很乱,而且一旦某个服务器的端口号或者域名有变动,那么所有的url都需要改变,成本太大.为了让代码看起来更简便, ...
- grafana-Admin密码重置
1)查看Grafana配置文件,确定grafana.db的路径 [paths] ;data = /var/lib/grafana [database] # For "sqlite3" ...
- 模型评估【PR|ROC|AUC】
这里主要讲的是对分类模型的评估. 1.准确率(Accuracy) 准确率的定义是:[分类正确的样本] / [总样本个数],其中分类正确的样本是不分正负样本的 优点:简单粗暴 缺点:当正负样本分布不均衡 ...
- Numpy系列(四)- 索引和切片
Python 中原生的数组就支持使用方括号([])进行索引和切片操作,Numpy 自然不会放过这个强大的特性. 单个元素索引 1-D数组的单元素索引是人们期望的.它的工作原理与其他标准Python序 ...
- Mac 终端美化方法
美化终端,主要是主题,字体,命令行提示3个方面. 主题 使用的主题是Solarized Dark主题. 安装主题: git clone git://github.com/altercation/sol ...
- 第六节: EF高级属性(二) 之延迟加载、立即加载、显示加载(含导航属性)
一. 简介 上一个章节中,也介绍了立即加载和延迟加载,但上一个章节是针对单表而言的,不含外键,立即也好,延迟也好,都是指单表中的数据.但本章节重点介绍的三种加载方式均是针对含(导航属性.外键)的情况下 ...
- Regularity criteria for NSE 5: $u_3,\om_3$
In [Zhang, Zujin. Serrin-type regularity criterion for the Navier-Stokes equations involving one vel ...
- Codeforces 1100F(线性基+贪心)
题目链接 题意 给定序列,$q(1\leq q \leq 100000) $次询问,每次查询给定区间内的最大异或子集. 思路 涉及到最大异或子集肯定从线性基角度入手.将询问按右端点排序后离线处理询问, ...
- 【汇总目录】C#
[2019年04月29日] C# textbox 自动滚动 [2019年02月07日] C#利用VUDP.cs开发网络通讯应用程序 [2019年02月06日] C#利用VINI.cs操作INI文件 [ ...
- Java同步容器
一.为什么会出现同步容器 Java的集合框架中,主要有四大类别:List,Set,Queue,Map List,Set,Queue接口分别继承了Collection接口,Map本身是一个接口. 注意C ...