📄 stringcompare.java
字号:
// operators/StringCompare.java
// TIJ4 Chapter Operators, Exercise 14, page 133
/* Write a method that takes two String arguments uses all the boolean
* comparisons to compare the two Stings and print the results. For the == and
* !=, also perform the equals() test. In main(), test your method with some
* different String objects.
*/
import org.greggordon.tools.*;
public class StringCompare {
static void f(boolean b) {if(b == true) P.rintln(true);
else P.rintln(false);}
static void stringTest(String s, String t) {
f(s == t);
f(s.equals(t));
f(t.equals(s));
f(s != t);
// f(!s);
//f(!t);
// s = s && t;
// s = s || t;
// s = ~t;
// s = s & t;
// s = s | t;
// s = s ^ t;
// s &= t;
// s ^= t;
// s |= t;
}
public static void main(String[] args) {
String s = "one", t = "two";
StringWork.stringTest(s, t);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -