小编Ins*_*ion的帖子

执行JAR时禁用箭头键

案件如下:

1)我有一个脚本somescript.sh.

2)在脚本结束时,有一个eval语句触发JAR的执行.

3)当执行JAR时,它会要求用户提供a/b/c选项作为可能的答案 - 重要的事实是这些问题来自JAR应用程序,因此关于问题的控制台"逻辑"被写入在Java中并没有放在脚本本身.

问题是:在执行JAR程序时,用户可以按箭头键,这将导致丑陋的结果,如^ [[A ^ [[B ^ [[C ^ [[D.

这个帖子澄清了丑陋的结果:为什么终端在Ubuntu中按下箭头键时显示"^ [[A""^ [[B""^ [[C""^ [[D"]?

问题:如何在执行JAR时禁用箭头键?

bash jar sh

10
推荐指数
1
解决办法
273
查看次数

Nested Classes, Inner Class

I created an object d, right after the constructor, then another object, f, in the main method. I need to understand why is Output giving an exception (Exception in thread "main" java.lang.StackOverflowError). However, if I don't create the object d after the constructor, the program runs with success.

public class OuterTwo {
   public OuterTwo() {
       System.out.println("OUTER!");
   }

   OuterTwo d = new OuterTwo();

   public static void main(String[] args) {
       OuterTwo f = new OuterTwo();           
   }
}
Run Code Online (Sandbox Code Playgroud)

java constructor class call

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

如果语句没有运行

字符串被解析为整数,因此if语句的条件正确设置.为什么if语句没有运行?为什么没有出现带有响应的MessageDialog?

 class process{
     public static void whoIs(){

         JFrame frame=new JFrame("The Oldest");
            String a=JOptionPane.showInputDialog(frame, "Enter, please, the first name and age:", "QUIZ: Who is the Oldest", JOptionPane.QUESTION_MESSAGE);
           String b=JOptionPane.showInputDialog(frame, "Enter, please, the second name and age:", "QUIZ: Who is the Oldest", JOptionPane.QUESTION_MESSAGE);


            String age1=a.replaceAll("[^\\d]","");
            String age2=a.replaceAll("[^\\d]","");



            String name1=a.replaceAll("\\d","");
            String name2=b.replaceAll("\\d","");


            int age1int=Integer.parseInt(age1);
            int age2int=Integer.parseInt(age2);



            if (age1int>age2int){
                JOptionPane.showMessageDialog(frame, name1+ " is the oldest!", "QUIZ: Who is the Oldest?", JOptionPane.INFORMATION_MESSAGE);
            }

            if (age2int>age1int) {
                JOptionPane.showMessageDialog(frame, name2+ " is the oldest!", "QUIZ: Who is …
Run Code Online (Sandbox Code Playgroud)

java if-statement joptionpane

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

HashSet排序算法,1-9位数

我继续讨论这个奇怪的话题:为什么HashSet类按升序排序1到9位数,尽管其余数字排序不是升序.我知道HashSet专注于速度的想法.但如果有人能够解释为什么只对1到9的数字进行排序,我将不胜感激.

例:

public static void main(String[] args) {
        int count[] = {3, 2, 3, 7, 6};
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < 5; i++) {
            set.add(count[i]);
        }
        System.out.println(set);
    }


Output: [2, 3, 6, 7]
Run Code Online (Sandbox Code Playgroud)

如果int count[] = {44,32,87,32,11}; 输出:[32,87,11,44]

java algorithm hashset

-1
推荐指数
1
解决办法
139
查看次数

标签 统计

java ×3

algorithm ×1

bash ×1

call ×1

class ×1

constructor ×1

hashset ×1

if-statement ×1

jar ×1

joptionpane ×1

sh ×1