[Java]char型文字を比較するサンプル

書式
char変数A >char変数B
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
package com.arkgame.study;
public class CharComDemo {
public static void main(String[] args) {
char cftA = 'A';
char cftB = '1';
int cftC = 49;
System.out.println("結果1:" + (cftA > cftB));
System.out.println("結果2:" + (cftA < cftB));
System.out.println("結果3:" + (cftB == cftC));
}
}
package com.arkgame.study; public class CharComDemo { public static void main(String[] args) { char cftA = 'A'; char cftB = '1'; int cftC = 49; System.out.println("結果1:" + (cftA > cftB)); System.out.println("結果2:" + (cftA < cftB)); System.out.println("結果3:" + (cftB == cftC)); } }
package com.arkgame.study;

public class CharComDemo {

      public static void main(String[] args) {
            char cftA = 'A';
            char cftB = '1';
            int cftC = 49;

            System.out.println("結果1:" + (cftA > cftB));
            System.out.println("結果2:" + (cftA < cftB));
            System.out.println("結果3:" + (cftB == cftC));
      }

}

結果1:true
結果2:false
結果3:true

Java

Posted by arkgame