「Java入門」BooleanとStringの型の変換サンプル

構文
String.valueOf(boolean値)
Javaコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
package com.arkgame.study.tm;
import java.util.ArrayList;
import java.util.List;
public class ListBooleanElem {
protected static List<Boolean> cft = null;
public static void main(String[] args) {
cft = new ArrayList<Boolean>();
cft.add(true);
cft.add(false);
cft.add(false);
System.out.println("実行結果");
// Boolean ->String
for (Boolean bn : cft) {
System.out.println(String.valueOf(bn.booleanValue()));
}
}
}
package com.arkgame.study.tm; import java.util.ArrayList; import java.util.List; public class ListBooleanElem { protected static List<Boolean> cft = null; public static void main(String[] args) { cft = new ArrayList<Boolean>(); cft.add(true); cft.add(false); cft.add(false); System.out.println("実行結果"); // Boolean ->String for (Boolean bn : cft) { System.out.println(String.valueOf(bn.booleanValue())); } } }
package com.arkgame.study.tm;

import java.util.ArrayList;
import java.util.List;

public class ListBooleanElem {

      protected static List<Boolean> cft = null;
      public static void main(String[] args) {

            cft = new ArrayList<Boolean>();

            cft.add(true);
            cft.add(false);
            cft.add(false);

            System.out.println("実行結果");
            // Boolean ->String
            for (Boolean bn : cft) {
                  System.out.println(String.valueOf(bn.booleanValue()));
            }

      }

}

結果
実行結果
true
false
false

Java

Posted by arkgame