小编jon*_*hua的帖子

在javadoc中,标签@throws和@exception之间有什么区别?

以下面的基于数组的字符堆栈的实现为例:

public char peek() throws Underflow {
    if (!isEmpty()) {
        return stack[pos];
    } else {
        throw new Underflow("Peeking at an empty stack.");
    }
}
Run Code Online (Sandbox Code Playgroud)

回到我只使用文本编辑器时,我总是使用@exception标签,但现在我的IDE(Netbeans)在生成javadoc时使用了@throws.

所以我的问题是,两者之间的差异是什么时候应该优先于另一个(例如使用上面的代码)?

java javadoc

31
推荐指数
3
解决办法
2万
查看次数

为什么我需要在HTML中注释<script>标记?

我见过的大多数例子都在html页面中包含脚本

<!--
...
-->
Run Code Online (Sandbox Code Playgroud)

我试过写它没有评论标签,似乎没有任何区别.为什么使用注释标签以及它提供的功能是什么?

html javascript tags comments

16
推荐指数
3
解决办法
7385
查看次数

如何使用assert来测试字符串

我正在尝试测试strcat()我自己编写的函数.我没有打印输出并手动逐行检查,而是决定使用assert.h中的assert.问题是即使输出看起来完全正常,断言也会显示错误.以下是我的代码:

void mystrcat_test()
{
    char str[BUFSIZ];
    assert(strcmp(str, ""));
    mystrcat(str, "hello");
    assert(strcmo(str, "hello"));
}
Run Code Online (Sandbox Code Playgroud)

c assert

5
推荐指数
2
解决办法
5778
查看次数

当用户尝试使用浏览器的导航按钮进行导航时,如何强制用户退出?

项目背景

客户要求在尝试使用浏览器的导航按钮进行导航时,必须强制注销站点的用户(登录并能够查看其个人信息时).

我的研究

在SO上搜索似乎表明,人们遇到的大多数问题是"阻止"人们在退出时点击浏览器的后退按钮,就像这样这样.不同之处在于我需要"停止"用户在历史记录中向后导航(甚至是向前导航,但我不知道如果用户不能首先返回,他们将如何在历史中前进)即使他们登录,也必须使用提供的导航.

我想到的解决方案

我正在考虑在用户点击后退按钮然后将其记录下来捕获浏览器的事件.但是,正如这里所讨论的那样,您似乎只能使用Javascript"执行此操作"而不使用服务器端代码.我对这种方法的质疑是,用户只需在浏览器上禁用Javascript就可以绕过它.

我的问题

所以我的问题是 - 有没有办法在服务器端捕获浏览器事件并将其记录在那里?如果没有,实现目标的替代方案是什么?

java jsp

4
推荐指数
1
解决办法
893
查看次数

Why am I getting a segmentation fault?

I'm trying to write a program that takes in a plaintext file as it's argument and parses through it, adding all the numbers together and then print out the sum. The following is my code:

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

static int sumNumbers(char filename[])
{
    int sum = 0;
    FILE *file = fopen(filename, "r");
    char *str;

    while (fgets(str, sizeof BUFSIZ, file))
    {
        while (*str != '\0')
        {
            if (isdigit(*str))
            {
                sum += atoi(str);
                str++;
                while (isdigit(*str))
                    str++;
                continue;
            } …
Run Code Online (Sandbox Code Playgroud)

c arrays pointers segmentation-fault

3
推荐指数
1
解决办法
495
查看次数

需要帮助找出无限循环

这是我的代码的简化版本:

void calc(char *s)
{
    int t = 0;
    while (*s)
    {
        if (isdigit(*s))
            t += *s - '0';
        else
            ++s;
    }
    printf("t = %d\n", t);
}

int main(int argc, char* argv[])
{
    calc("8+9-10+11");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

问题是while循环运行永远,虽然我希望它在最后一位数后停止1.而我的预期输出是t = 20.

c infinite-loop while-loop

3
推荐指数
1
解决办法
135
查看次数

是否有适用于Mac的独立,轻量级,基于GUI的Java调试工具?

我是一名CS学生,所以显然IDE对我来说有点过分.我主要用Vim编写代码(技术上很好的MacVim)并使用终端编译和运行.在过去,我通常使用print语句进行调试.但是我觉得现在是时候根据我的需要选择更合适的工具了.我听说过并试过jdb,但我更喜欢GUI.有人推荐吗?

java debugging macos

3
推荐指数
1
解决办法
2548
查看次数

最奇怪的分段错误

好吧,基本上我正在编写一个程序,它接收两个目录并根据提供的选项处理它们.当我没有看到问题时,它会给我分段错误.导致问题的代码如下:

编辑:更新代码以包含我的整个源文件

#include <unistd.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>

#define OPTLIST "am:npruv"
#define DEFAULT_MOD_TIMES 1

typedef struct
{
    /* Boolean toggle to indicate whether hidden files should be
       processed or not */
    bool processHiddens;
    /* Integer number of seconds such that files with modification
       times that differ by less than this value are considered the
       same */
    int timeResolution;
    /* Boolean toggle to indicate whether the actual synchronisation
       (file creation and overwriting) should be performed or not */
    bool …
Run Code Online (Sandbox Code Playgroud)

c bash segmentation-fault

2
推荐指数
1
解决办法
777
查看次数

为什么我收到"没有效果的声明"警告?

以下是我的代码

/* Initialise default without options input. */
options -> processHiddens = false;
options -> timeResolution = DEFAULT_MOD_TIMES;
options -> performSync = true;
options -> recursive = false;
options -> print = false;
options -> updateStatus = true;
options -> verbose = false;
options -> programname = malloc(BUFSIZ);
options -> programname = argv[0];

while ((opt = getopt(argc, argv, OPTLIST)) != -1)
{
    switch (opt)
    {
        case 'a':
            !(options -> processHiddens);
        case 'm':
            options -> timeResolution = atoi(optarg);
        case 'n':
            !(options …
Run Code Online (Sandbox Code Playgroud)

c structure compiler-warnings

0
推荐指数
2
解决办法
1万
查看次数