Home > Back-end >  7, in JAVA equals (), and using the ternary operator
7, in JAVA equals (), and using the ternary operator

Time:09-20

Public class test03 {
Public void test01 () {
//the equals () : judgment equal
Strings Str1="ABC";
String Str2="ABC";
String Str3="aaa";
System. The out. Println (Str1. Equals (Str2));
System. The out. Println (Str1. Equals (Str3));

}
Public void test02 () {
//the ternary operator
//judgment conditions: 10 & gt; 2, if it is true, perform "hello"; If false, the execution of "world"
String result1=10 & gt; 2? "Hello", "world";
String result2=10 & lt; 2? "Hello", "world";
System. The out. Println (result1);
System. The out. Println (result2);
}
Public static void main (String [] args) {
Test03 test=new test03 ();
Test. Test01 ();
Test. Test02 ();

}
}

CodePudding user response:

This is to write a blog