- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在制作有界数组堆栈。此方法将大于存储容量的数组抛出到 StackOverflowException
,除了我不断收到“throws StackOverflowException
部分
public void push(T item) throws StackOverflowException {
//push item onto the stack,
if (isFull()) throw new StackOverflowException();
else {
top++;
storage[top] = item;
}
}
错误信息:
Error:(52, 17) java:
push(T)
incom.ld.BoundedArrayStack
cannot implementpush(T)
incom.ld.StackADT
overridden method does not throwcom.ld.StackOverflowException
其他信息:
push(T)
incom.Id.BoundedArrayStack
clashes withpush(T)
incom.Id.StackADT
; overridden method does not throwcom.Id.StackOverflowException
我不明白这是什么问题。
最佳答案
根据您的错误消息,您的父类(super class) StackADT
定义了 push
不抛出 StackOverflowException
,因此此方法的任何覆盖都不会抛出 StackOverflowException
要么。
您可以:
StackOverflowException
设为RuntimeException
,它可以随时抛出。您不必在 throws
子句或 StackADT
中声明 push
方法,以便它throw
StackOverflowException
。关于java - 如何抛出 StackOverflowException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33577941/
dataElementsList : TypesAndData.DataElement list 是一个包含 50,000 条记录的列表(实际上更多,但让我们从小处开始)。我正在尝试序列化为 JSON
我试图序列化一个自定义类型,该类型在其他成员中包含一个字典。与字典的键和值相关联的类型是实现的接口(interface)。 字典看起来像 Dictionary TypeA implements IT
我有一个 C# 工厂对象,它使用对象列表作为源,通过工厂方法创建对象。 对象列表的创建方式如下: public WidgetFactory() { widgetLibrary
我正在 GenericList 类中实现递归快速排序方法。我将有第二种方法,它接受一个compareDelegate来比较不同的类型,但出于开发目的,我对GenericList进行排序。 我根据列表大
我为我的作业编写了一种方法,用于通过递归计算整数数组的所有排列。 (我正在尝试实现回溯算法)。但计算超过 7 个数字的前突变时会导致 StackOverflowException 。我不知道如何解决这
我正在尝试将一个大文件拆分成许多小文件。每个拆分发生的位置基于检查每个给定行的内容返回的谓词(isNextObject 函数)。 我试图通过 File.ReadLines 函数读取大文件,这样我就可以
我正在使用 onSuccessCallBack() 接口(interface)方法同步大量数据。按照如图所示的方法将数据发送到服务器。在这里我面临 StackOverflowException 的问题
我必须递归调用一个函数。但片刻之后它会抛出 StackOverFlowException。当我使用 Invoke(new Action(Start)) 方法时,它会抛出相同的异常,但不会在很长一段时间
我有一些依赖于 HttpContext.Cache 的代码,我希望它在满足特定条件时重新缓存某些内容。但是,这会引入潜在的堆栈溢出,我不确定这里的适当方法是什么。 看看这段代码: void OnCac
我将我的代码剥离到导致问题的部分。代码在这里来回跳转第5行和第9行,导致stackoverflowexception。 我该如何做呢?我需要 Game 类中的 Platform 实例才能在函数中使用。
我的问题很简单。我有这个新表格,我只是编写代码: public partial class Form1 : Form { public Form1() { In
根据我的question (通用方法的可重用非通用方法)我已经实现了提供的解决方案,但经过一些重构(将代码移动到基类)后,我的代码导致了我不理解的 StackOverflowException。 调用
背景。我的脚本在递归搜索大字符串中的特定文本时遇到 StackOverflowException。循环不是无限的;问题发生在 9,000-10,000 次合法搜索之间(对于特定搜索)——我需要它继续进
请帮助我解决 System.StackOverflowException我想用 .aspx 将记录写入数据库我使用 4 层架构来实现这一切都正常但是当我编译页面然后它显示要插入数据的字段时,当我将数据
我正在尝试回答 my own old question基于我唯一的(无效的)答案。 这个想法是为了简化按值排序的映射的创建: public class SortedByValueMap> implem
我目前正在制作有界数组堆栈。此方法将大于存储容量的数组抛出到 StackOverflowException,除了我不断收到“throws StackOverflowException 部分”的错误消息
我正在使用以下方法递归迭代对象的属性: void GetProps(object obj) { if (obj == null) return; var objType
我想做一个非常简单的任务,它以某种方式使程序崩溃。 我有一个包含数字的列表,所有数字都是唯一的。超过一定数量,我想倒序。 示例:5, 16, 11, 3, 8, 4 -> 5, 16, 11, 4,
我正在尝试编写一个函数来检查字符串是否为回文,并使用 this example ,我正在尝试使用递归匿名函数反转字符串: static Boolean checkPalindromeAnonRec(s
这段代码有什么问题?我不断收到 StackOverlflowException.. public class Places { public string Title { get; set;
我是一名优秀的程序员,十分优秀!