【发布时间】:2015-12-02 02:31:12
【问题描述】:
我正在制作一个新的转换软件来隐藏消息(为了好玩)。我做了一个二进制和十进制转换类,我的想法是,用户输入字符串,它将全部转换为二进制格式。然后将其分成两半,将一半转换为十进制,然后将字符串重新加在一起,使其成为二进制和十进制的混合。在其他版本中,我将添加更多转换、更多拆分,并且可能还会转换为语言。我需要将字符串分成两半。到目前为止,这是我的代码::
public ray() {
Scanner in = new Scanner(System.in);
while (true) {
System.out.println("Please input the text you wish to encode!");
System.out.println("Type '#' to quit the Software.");
String s1 = in.nextLine();
if ("#".equalsIgnoreCase(s1)) {
System.out.println("Goodbye, hope you enjoyed RAYConversion v1.0 Alpha.");
// close software
}
// convert all to binary
binary Binary = new binary();
//what i need to do is split stirng s1 in half, make it into different strings. Then I will convert
//the two strings to binary and decimal. I made a converter for that.
}
}
【问题讨论】:
-
如何将字符串“AAA”一分为二?
-
请使用命名约定。一个名为
ray的类应称为Ray,而binary Binary应为Binary binary- 具有一个类Binary和一个变量binary。另外,'#'的大写/小写是什么,考虑到您在String上调用equalsIgnoreCase()时只有那个字符? -
我对 Java 有点陌生,它对我有用,equalsIgnoreCase 可能是我知道的 equals,我习惯使用 Bukkit API 大声笑,我使用 equalsIgnoreCase 作为命令。 AAA,下半场是 AA,前半场是 A。
标签: java arrays string split binary