RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-14981

alvoro's questions

Martin Hope
alvoro
Asked: 2020-09-20 02:10:41 +0000 UTC

如何确定发生了类导入?

  • 5

是否有 Java 库允许您在编译时确定将某个类导入到不需要的地方?

我怎么看:

@VisibleFor(some.packagee.name)
public class AlmostPublic {
    // ...
}

现在尝试AlmostPublic在包外的任何地方导入类some.packagee.name应该会引发编译错误。

java
  • 2 个回答
  • 10 Views
Martin Hope
alvoro
Asked: 2020-09-05 04:13:36 +0000 UTC

java编译器,泛型和继承

  • 3

有一个特定的通用接口和一个实现它的类。

interface Contract<T> {
    void doIt(T arg);
}

class Impl implements Contract<Integer> {

    @Override
    public void doIt(Integer arg) {
        System.out.println("hi");
    }
}

当创建一个实例Impl并调用这样的方法时

Contract obj = new Impl();
obj.doIt(42);

编译器礼貌地警告 Unchecked call ... 。

我得出以下结论 - 编译器不会查看实际会调用哪个类方法。在这里,他看着他们Contract#doIt(T arg)正在拉动的东西,并警告说有必要转移类型。并且将类型转移到将完成所有工作的类的事实对其隐藏。

我理解正确吗?

java
  • 1 个回答
  • 10 Views
Martin Hope
alvoro
Asked: 2020-08-31 01:00:22 +0000 UTC

将抽象类转换为具体实现

  • 4

有一个方法返回一个抽象类的实例和接受所有现有后代的重载方法。

AbstractClass getSuccessor() {
    return ...;
}

void work(SonOfAbstract child);

void work(DaughterOfAbstract child);

void work(GrandchildOfAbstract child);

该方法getSuccessor()保证返回一个继承人AbstractClass,并且该方法work可以与所有继承人一起使用。

但是调用work(getSuccessor());没有按预期通过,因为方法work(AbstractClass child)没有定义。在真空中没有父母和球形孩子的工作。

如何将继承人传递给方法,并让 JRE 确定要调用的方法?

java
  • 2 个回答
  • 10 Views
Martin Hope
alvoro
Asked: 2020-07-23 03:48:19 +0000 UTC

注释作为 Android Studio 中的标题

  • 0

有没有办法在 android studio a la outline/outshine-mode 在 emacs 中通过评论来安排折叠?

换句话说,这段代码

class SomeClass {
    // * group of related methods 1
    void method1() { ... }
    void method2() { ... }
    void method3() { ... }
    void method4() { ... }

    // * group of related methods 2
    void method1() { ... }
    void method2() { ... }
    void method3() { ... }
    void method4() { ... }

    // * group of related methods 3
    void method1() { ... }
    void method2() { ... }
    void method3() { ... }
    void method4() { ... }

}

像这样卷起来

class SomeClass {
    // * group of related methods 1 ... (типо свернули)

    // * group of related methods 2
    void method1() { ... }
    void method2() { ... }
    void method3() { ... }
    void method4() { ... }

    // * group of related methods 3 ... (типо свернули)
android-studio
  • 1 个回答
  • 10 Views
Martin Hope
alvoro
Asked: 2020-05-10 02:56:14 +0000 UTC

创建一个实体类和一个负责处理一组实体的类

  • 0

从java到你,所以问题可能是微不足道的。有两个类 -Something和SomethingGroup。受到以下事实的启发:在 android-framework 中,它ViewGroup继承自以及将混合和存储在一个列表中View的便利性,直接继承自:SomethingSomethingGroupSomethingGroupSomething

class Something {
    private String name;
    private int count;

    public Something(String name, int count) {
        this.name = name;
        this.count = count;
    }

    public int getCount() {
        return count;
    }
}

class SomethingGroup extends Someting {
    private String name;
    ArrayList<Something> children;

    SomethingGroup(String name, Something ... children) {
        // super(и вот что ему сюда передать?)
        this.name = name;
        this.children = new ArrayList<>(Arrays.asList(children));
    }

    public int getCount() {
        int count = 0;
        for(Something s : children) {
            count += s.getCount();
        }
        return count;
    }
}

问题出在财产count上。在创建对象Something时,我们知道它的值,可以直接将其传递给构造函数,而在创建SomethingGroup这个值时,这个值是“间接”传递的,必须进行计算。在这种情况下如何行事?

java
  • 2 个回答
  • 10 Views
Martin Hope
alvoro
Asked: 2020-02-16 02:56:57 +0000 UTC

注意主要选择的变化

  • 0

你好。一个脚本已经在 Internet 上流传了很长时间,它允许您在任何应用程序中翻译选定的文本。算法很简单——通过调用脚本,我们读取主要选择的内容(xsel 到帮助),向 Google 翻译器发送请求并通过例如 notify-send 显示结果。当主要选择发生变化时如何自动调用此脚本?

linux
  • 1 个回答
  • 10 Views
Martin Hope
alvoro
Asked: 2020-08-10 05:32:20 +0000 UTC

还原多个 git 附加组件

  • 1

你好。

git init
echo first > file
git add file
echo second > file
git add file
echo third > file
git add file

执行这些命令后如何获取添加到索引的文件的第一或第二版本?

git
  • 1 个回答
  • 10 Views
Martin Hope
alvoro
Asked: 2020-02-10 21:54:39 +0000 UTC

无法从脚本创建别名

  • 0

创建了一个包含以下内容的文件:

#!/bin/bash

alias some='echo 2'

赋予他执行权,脚本执行时什么也没有发生(不创建别名)。我究竟做错了什么?bash 版本 - 4.3.46

bash
  • 1 个回答
  • 10 Views
Martin Hope
alvoro
Asked: 2020-10-26 00:43:00 +0000 UTC

交换 caps 和 lctrl

  • 0

你好。我想做以下事情:

  1. 交换大写字母和 ctrl;
  2. 自定义切换器 - 对我们的上限和 Shift + 对 ru 的上限
  3. 突出显示英文布局上的 Scroll Lock 灯。

这是我提供给 xkbcomp 的配置:

xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   {
        // include "pc+us+ru:2+inet(evdev)+group(shift_caps_switch)"

        replace key <CAPS> { [ Control_L ] };
        replace key <LCTL> { [ Caps_Lock ] };
        include "pc+us+ru:2+inet(evdev)+group(shift_caps_switch)"

    };
    xkb_geometry  { include "pc(pc105)" };
};

问题是所有的东西都不是立刻给出的——要么按钮改变了,要么布局切换被配置了。怎样成为?

клавиатура
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5