黃柏諺java data type 資料型態
/*黃柏諺2022/10/24JJava data type,資料型態*/
public class Main {
public static void main(String[] args) {
int myNum = 5; // 宣告整數integer (whole number),4位元組bytes
float myFloatNum = 5.99f; // floating point number,4位元組bytes
double doubleNum = 5.99d; //倍精數,8位元,8bytes,和 long常整數
char myLetter = 'D', littlepig= 'd'; // 字元character=角色,2位元組bytes=16位元bits
boolean myBool = true; // 布林boolean1ean,1位元bit,0或1,false or true
String myText = "黃柏諺"; // 字串String,非原形資料,長度變動的
System.out.println(myNum); //系統的,輸出的,列印print且換列ln=line
System.out.println(myFloatNum);
System.out.println(myLetter);
System.out.println(myBool);
System.out.println(myText);
myNum = myLetter; System.out.println(myNum);
myNum = littlepig; System.out.println(myNum);
for (int k=1; k <10; k=k+4)
System.out.print(k + " ");
}
}
/*黃柏諺2022/10/24JJava data type,資料型態*/ public class Main { public static void main(String[] args) { int myNum = 5; // 宣告整數integer (whole number),4位元組bytes float myFloatNum = 5.99f; // floating point number,4位元組bytes double doubleNum = 5.99d; //倍精數,8位元,8bytes,和 long常整數 char myLetter = 'D', littlepig= 'd'; // 字元character=角色,2位元組bytes=16位元bits boolean myBool = true; // 布林boolean1ean,1位元bit,0或1,false or true String myText = "黃柏諺"; // 字串String,非原形資料,長度變動的 System.out.println(myNum); //系統的,輸出的,列印print且換列ln=line System.out.println(myFloatNum); System.out.println(myLetter); System.out.println(myBool); System.out.println(myText); myNum = myLetter; System.out.println(myNum); myNum = littlepig; System.out.println(myNum); for (int k=1; k <10 k="" pre="" system.out.print="">
留言
張貼留言