วันอาทิตย์ที่ 19 สิงหาคม พ.ศ. 2550
+++++ Array Homework+++++


+++++ ผล +++++
กรณีใส่ค่าถูกต้อง
----- ข้อ 2 -----



วันพุธที่ 15 สิงหาคม พ.ศ. 2550
* * * T E S T M i d t e r m * * *

OUTPUT
กรณีที่ 1 ใส่ค่าถูกต้อง

กรณีที่ 2 ใส่ค่าไม่ถูกต้อง

***** ข้อที่ 2 *****



OUTPUT

***** ข้อที่ 3 *****



OUTPUT
กรณีที่ 1 ใส่ค่าไม่ถูกต้อง

กรณีที่ 2 ใส่ค่าถูกต้อง
* * * LOOP * * *
ชนิดข้อมูลพื้นฐาน <ตัวแปร>
-> ตัวแปรที่เป็นเลขทศนิยมสามารถใช้เก็บจำนวนเต็มได้ แต่ไม่สามารถ ใช้เก็บตัวอักษรได้ เป็นต้น
>>> ชนิดของตัวแปรจะถูกระบุเมื่อเราประกาศตัวแปร มีรูปแบบ คือ ชนิดข้อมูล ชื่อตัวแปร ;
-> int count ; ( int = ชนิดข้อมูล , count = ชื่อตัวแปร)
>>> byte : 8 บิต : -128 ถึง 127
short: 16 บิต : -32768 ถึง 32767
int : 32 บิต : -2147483468 ถึง 2147483467
long : 64 บิต : เลขลบเยอะมาก ถึง เลขบวกเยอะมาก
float : 32 บิต : เก็บเลขทศนิยม และเลขยกกำลัง
double : 64 บิต : เก็บเลขทศนิยมและเลขยกกำลังได้ละเอียดกว่า float
boolean : แล้วแต่ JVM จะกำหนด : true หรือ false
char : 16 บิต : ใช้กับอักขระที่มีรหัสตั้งแต่ 0 ถึง 655535
-> ภาษา Java มี type wrapper classes ของชนิดข้อมูลเลขจำนวนเต็มคือ Byte, Short, Integer และ Long คลาสเหล่านี้มีค่าคงที่ ซึ่งกำหนดค่าสูงสุด และต่ำสุดของชนิดข้อมูลนั้นดังนี้
public class IntegerConstants {
public static void main(String args[]) {
System.out.println(Byte.MAX_VALUE);
System.out.println(Byte.MIN_VALUE);
System.out.println(Short.MAX_VALUE);
System.out.println(Short.MIN_VALUE);
System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);
System.out.println(Long.MAX_VALUE);
System.out.println(Long.MIN_VALUE);
}
}
-> การแสดงค่าข้อมูลของตัวแปรแต่ละชนิด
class SimpleTypes{
public static void main(String args[]){
byte b = 0x55; short s = 0x55ff;
int i = 1000000; long l = 0xffffffffL;
char c = ‘a’; float f = .25f;
double d = .00001234; boolean bool = true;
System.out.println(“byte b = “ + b); System.out.println(“short s = “ + s);
System.out.println(“int I = ” + i); System.out.println(“long = “ + 1);
System.out.println(“char c = “ + c); System.out.println(“float f = f “ + f);
System.out.println(“double d = “ + d);
System.out.println(“Boolean bool = “ + bool);
}
}
credit by : http://sourcecode.in.th/lession.asp?no=13&group=2
www.cs.su.ac.th/~kanawong/courses/517211/slide/517211_lab04.ppt
หนังสือ เขียนโปรแกรม Java เบื้องต้น โดย วรเศรษฐ สุวรรณิก และ ทศพล ธนะทิพานนท์
รัตติยา 484 37539 27 ว่าน





