经过一些在线搜索后,我发现以下命令应该从 bash 历史记录中删除单个条目:
$ history -d <number>
Run Code Online (Sandbox Code Playgroud)
假设我想从我的历史记录中删除这一行,因为我拼错了 git :
10003 gti add . && git commit -m
Run Code Online (Sandbox Code Playgroud)
当我执行以下命令时:
$ history -d 10003
Run Code Online (Sandbox Code Playgroud)
即使我重新启动终端,它仍然显示在我的历史记录中
所以我知道如何解决这个问题,因为我使用自动完成功能,有时尤其是在使用 git 时,它可能会变得有点混乱。
bash terminal command-line autocomplete windows-subsystem-for-linux
我知道何时为字段和构造函数使用关键字"this"但我不确定它何时作为参数传递
import javax.swing.*;
import java.awt.event.*;
public class SimpleGui implements ActionListener {
JButton button;
public static void main (String[] args) {
SimpleGui gui = new SimpleGui();
gui.go();
}
public void go() {
JFrame frame = new JFrame();
button = new JButton("click me");
button.addActionListener(this);
frame.getContentPane().add(button);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 300);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent event) {
button.setText("I've been clicked!");
}
}
Run Code Online (Sandbox Code Playgroud) 为什么是输出?:球体 0
它以某种方式隐式调用 toString() 方法?这是如何运作的 ?
class BerylliumSphere {
private static long counter = 0;
private final long id = counter++;
public String toString() {
return "Sphere " + id;
}
}
public class Test {
public static void main (String[] args) {
BerylliumSphere spheres = new BerylliumSphere();
System.out.println(spheres);
}
}
// output: Sphere 0
Run Code Online (Sandbox Code Playgroud) java ×2
autocomplete ×1
bash ×1
command-line ×1
implicit ×1
keyword ×1
printing ×1
terminal ×1
this ×1
tostring ×1