「Java14」equals()メソッドでShortの値を比較するサンプル

2020年12月16日

構文
equals(Short s)
引数の値と同じかどうかを返します
実行環境 Java14
サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
package com.arkgame.study;
public class ShortSujiShDemo {
protected static String cftA = "678";
public static void main(String[] args) {
Short stA = Short.valueOf(cftA);
Short stB = Short.valueOf("678");
boolean result = stA.equals(stB);
System.out.println("Short型AとShort型Bの比較結果: " + result);
}
}
package com.arkgame.study; public class ShortSujiShDemo { protected static String cftA = "678"; public static void main(String[] args) { Short stA = Short.valueOf(cftA); Short stB = Short.valueOf("678"); boolean result = stA.equals(stB); System.out.println("Short型AとShort型Bの比較結果: " + result); } }
package com.arkgame.study;

public class ShortSujiShDemo {

      protected static String cftA = "678";

      public static void main(String[] args) {

            Short stA = Short.valueOf(cftA);
            Short stB = Short.valueOf("678");

            boolean result = stA.equals(stB);
            System.out.println("Short型AとShort型Bの比較結果: " + result);

      }

}

実行結果
Short型AとShort型Bの比較結果: true

Java

Posted by arkgame