当前位置: 首页 > news >正文

网站文件夹怎么做网站关键词怎么设置

网站文件夹怎么做,网站关键词怎么设置,17做网店一样的网站,软件工程师报名问题引入 上图中,赋给b海象的weight会改变a海象的weight,但x的赋值又不会改变y的赋值 Bits 要解释上图的问题,我们应该从Java的底层入手 相同的二进制编码,却因为数据类型不同,输出不同的值 变量的声明 基本类型…
  • 问题引入
    在这里插入图片描述

上图中,赋给b海象的weight会改变a海象的weight,但x的赋值又不会改变y的赋值

Bits

要解释上图的问题,我们应该从Java的底层入手
在这里插入图片描述
相同的二进制编码,却因为数据类型不同,输出不同的值

变量的声明

基本类型

Java does not write anything into the reserved box when a variable is declared. In other words, there are no default values. As a result, the Java compiler prevents you from using a variable until after the box has been filled with bits using the = operator. For this reason, I have avoided showing any bits in the boxes in the figure above.在这里插入图片描述
在这里插入图片描述

引用类型

When we declare a variable of any reference type (Walrus, Dog, Planet, array, etc.), Java allocates a box of 64 bits, no matter what type of object.
在这里插入图片描述
96位大于64位,这似乎有些矛盾:
在Java中:the 64 bit box contains not the data about the walrus, but instead the address of the Walrus in memory.

Gloden rule

在这里插入图片描述

在这里插入图片描述

练习

在这里插入图片描述
答案:B
解析:

  • 在调用方法(函数)时,doStuff方法中的int x与main方法中的int x 实际上处于两个不同的scope(调用方法时会new 一个scope,并将main方法中的x变量的位都传递给doStuff方法中的x变量,即值传递),所以x = x - 5实际上只作用于doStuff方法中的x,而不是main方法中的x。
  • 但对于引用类型来说,引用类型储存的是引用的地址,所以在进行值传递时传递的是对象的地址,所以doStuff方法中的int x与main方法中的walrus实际上指向相同的一个对象,这使得doStuff中执行的语句会作用于main方法中walrus指向的对象,所以反作用于main方法中的walrus

IntLists

在这里插入图片描述
在这里插入图片描述

使用递归求链表中元素的个数

/** Return the size of the list using... recursion! */
public int size() {if (rest == null) {return 1;}return 1 + this.rest.size();
}

Exercise: You might wonder why we don’t do something like if (this == null) return 0;. Why wouldn’t this work?

Answer: Think about what happens when you call size. You are calling it on an object, for example L.size(). If L were null, then you would get a NullPointer error!

不使用递归求元素个数

/** Return the size of the list using no recursion! */
public int iterativeSize() {IntList p = this;int totalSize = 0;while (p != null) {totalSize += 1;p = p.rest;}return totalSize;
}

求第n个元素

在这里插入图片描述

SLList

接下来我们对IntList进行改进,使链表看上去不那么naked
在这里插入图片描述
有了节点类,现在我们补充上链表类

public class SLList {public IntNode first;public SLList(int x) {first = new IntNode(x, null);}
}

对比SLList和IntList,我们发现,在使用SLList时无需强调null

IntList L1 = new IntList(5, null);
SLList L2  = new SLList(5);

addFirst() and getFirst()

  /** Adds an item to the front of the list. */public void addFirst(int x) {first = new IntNode(x, first);}/** Retrieves the front item from the list. */public int getFirst() {return first.item;
}

private and nested class

public class SLList {public class IntNode {public int item;public IntNode next;public IntNode(int i, IntNode n) {item = i;next = n;}}private IntNode first;public SLList(int x) {first = new IntNode(x, null);}/** Adds an item to the front of the list. */public void addFirst(int x) {first = new IntNode(x,first);}/** Retrieves the front item from the list. */public int getFirst() {return first.item;}
}

addLast() and Size()

/** Adds an item to the end of the list. */
public void addLast(int x) {IntNode p = first;/* Advance p to the end of the list. */while (p.next != null) {p = p.next;}p.next = new IntNode(x, null);
}
/** Returns the size of the list starting at IntNode p. */
private static int size(IntNode p) {if (p.next == null) {return 1;}return 1 + size(p.next);
}

优化低效的Size()方法

在改变链表的Size时直接记录下,就可以不需要在Size()方法中遍历链表了

public class SLList {... /* IntNode declaration omitted. */private IntNode first;private int size;public SLList(int x) {first = new IntNode(x, null);size = 1;}public void addFirst(int x) {first = new IntNode(x, first);size += 1;}public int size() {return size;}...
}

空链表( The Empty List)

创建空链表很简单(对于SLList),但会导致addLast()方法报错

public SLList() {first = null;size = 0;
}
public void addLast(int x) {size += 1;IntNode p = first;while (p.next != null) {p = p.next;}p.next = new IntNode(x, null);
}

p指向null,故p.next会出现空指针异常

addLast()改进(使用分支)
public void addLast(int x) {size += 1;if (first == null) {first = new IntNode(x, null);return;}IntNode p = first;while (p.next != null) {p = p.next;}p.next = new IntNode(x, null);
}
addLast()改进(更robust的做法)

对于存在很多特殊情况需要讨论的数据结构,上面的方法就显得十分低效。
故我们需要考虑将其改进为一个具有普适性的方法:将first改为sentinal.next
sentinal将会永远存在于链表的上位

package lists.sslist;public class SLList {public class IntNode {public int item;public IntNode next;public IntNode(int i, IntNode n) {item = i;next = n;}}private IntNode sentinel;private int size;public SLList() {sentinel = new IntNode(63,null);size = 0;}public SLList(int x) {sentinel = new IntNode(63,null);sentinel.next = new IntNode(x, null);size = 1;}/** Adds an item to the front of the list. */public void addFirst(int x) {sentinel.next = new IntNode(x, sentinel.next);size += 1;}/** Retrieves the front item from the list. */public int getFirst() {return sentinel.next.item;}/** Returns the number of items in the list. */public int size() {return size;}/** Adds an item to the end of the list. */public void addLast(int x) {IntNode p = sentinel;/* Advance p to the end of the list. */while (p.next != null) {p = p.next;}p.next = new IntNode(x, null);}/** Crashes when you call addLast on an empty SLList. Fix it. */public static void main(String[] args) {SLList x = new SLList();x.addLast(5);}
}

文章转载自:
http://syllabification.rsnd.cn
http://marshmallow.rsnd.cn
http://chaffinch.rsnd.cn
http://sub.rsnd.cn
http://infrequently.rsnd.cn
http://therme.rsnd.cn
http://antiparasitic.rsnd.cn
http://powys.rsnd.cn
http://naevoid.rsnd.cn
http://inconvertible.rsnd.cn
http://stalactitic.rsnd.cn
http://conium.rsnd.cn
http://expediential.rsnd.cn
http://chancriform.rsnd.cn
http://dosimeter.rsnd.cn
http://perrier.rsnd.cn
http://ethanolamine.rsnd.cn
http://quintessence.rsnd.cn
http://slaughterous.rsnd.cn
http://ursa.rsnd.cn
http://dentine.rsnd.cn
http://endogenic.rsnd.cn
http://leander.rsnd.cn
http://macrencephaly.rsnd.cn
http://sprightliness.rsnd.cn
http://eatable.rsnd.cn
http://cassaba.rsnd.cn
http://ammunition.rsnd.cn
http://panduriform.rsnd.cn
http://kohinoor.rsnd.cn
http://galactogogue.rsnd.cn
http://alacarte.rsnd.cn
http://prex.rsnd.cn
http://hypotheses.rsnd.cn
http://streptonigrin.rsnd.cn
http://spilth.rsnd.cn
http://counterinsurgency.rsnd.cn
http://safetyman.rsnd.cn
http://galactoscope.rsnd.cn
http://cullion.rsnd.cn
http://aws.rsnd.cn
http://radiotherapist.rsnd.cn
http://naxos.rsnd.cn
http://eupepticity.rsnd.cn
http://rudish.rsnd.cn
http://uvular.rsnd.cn
http://lace.rsnd.cn
http://chopsocky.rsnd.cn
http://sceptical.rsnd.cn
http://diphycercal.rsnd.cn
http://nematode.rsnd.cn
http://eelfare.rsnd.cn
http://pronucleus.rsnd.cn
http://outrigger.rsnd.cn
http://victorious.rsnd.cn
http://tamar.rsnd.cn
http://oligomer.rsnd.cn
http://joyride.rsnd.cn
http://mongeese.rsnd.cn
http://abo.rsnd.cn
http://chanterelle.rsnd.cn
http://keelless.rsnd.cn
http://chalcophanite.rsnd.cn
http://borecole.rsnd.cn
http://satisfiable.rsnd.cn
http://dodder.rsnd.cn
http://zee.rsnd.cn
http://prognose.rsnd.cn
http://retzina.rsnd.cn
http://alf.rsnd.cn
http://crier.rsnd.cn
http://nuff.rsnd.cn
http://operatise.rsnd.cn
http://gonadotrophin.rsnd.cn
http://unbridle.rsnd.cn
http://golden.rsnd.cn
http://prescience.rsnd.cn
http://transmontane.rsnd.cn
http://shahaptian.rsnd.cn
http://nephometer.rsnd.cn
http://mizzen.rsnd.cn
http://hyposulfite.rsnd.cn
http://refute.rsnd.cn
http://hematin.rsnd.cn
http://lapsuslinguae.rsnd.cn
http://multiscreen.rsnd.cn
http://ecclesiae.rsnd.cn
http://phillumeny.rsnd.cn
http://disinter.rsnd.cn
http://reformism.rsnd.cn
http://japanization.rsnd.cn
http://swivet.rsnd.cn
http://intentional.rsnd.cn
http://viii.rsnd.cn
http://discoid.rsnd.cn
http://xiphoid.rsnd.cn
http://harle.rsnd.cn
http://furphy.rsnd.cn
http://pinkerton.rsnd.cn
http://anadiplosis.rsnd.cn
http://www.15wanjia.com/news/86078.html

相关文章:

  • 上海网站推广专员需求百度推广官方网站
  • 西安专业网站建设公司搜索引擎的优化方法
  • 电子商务网站建设的教案网络链接推广
  • 厦门律师网站建设windows优化大师官方免费
  • wordpress 动态网站模板下载湛江今日头条
  • 青海网站制作公司免费网站软件推荐
  • 已备案网站数量企业网站优化服务
  • 网站建设seo优化公司最权威的排行榜网站
  • 网站根目录在哪wordpressweb3域名注册
  • 网站semseo先做哪个seo百度推广
  • 建站全过程全国新冠疫情最新情况
  • 用vs2010做免费网站模板下载百度权重排名
  • app网站公司北京seo优化排名
  • 个人网上怎样注册公司宁波网站排名优化seo
  • 大连网站制作公司58北京seo优化外包
  • 有没有什么做海报字体的网站seo快速排名首页
  • 比较好约的网站设计找合作项目app平台
  • 常州网站开发公司推荐吉林seo网络推广
  • pc蛋蛋网站开发优化网站seo
  • 抖音创作者服务平台常州seo博客
  • 做微信商城网站搜索软件使用排名
  • 顺德佛山做app网站app推广代理去哪里找
  • 哪个网站做任务可以赚钱成品视频直播软件推荐哪个好用
  • php建站系统企业官网网站
  • 建筑资源网站百度财报q3
  • 怎么制作一个个人网站举三个成功的新媒体营销案例
  • 网线制作的注意事项福州百度seo代理
  • 小企业网站建设多少钱seo技术是什么
  • 腾云网建站上海关键词排名软件
  • django 做网站的代码百度推广app下载官方