Reference :: Java ::
จัดทำโดย
นำยจิตติ เจริญศิลป์ เลขที่ 5 สทส.1/1
นำยอนิวรรต หนิ้วบุรุษ เลขที่ 7 สทส.1/1
นำยภูมิรพี สัทธินทรีย์ เลขที่ 12 สทส.1/1
Reference :: Java ::
DecimalFormat Class ::
:: new DecimalFormat ()
method : new DecimalFormat ();
return type : DecimalFormat
content : ใช้สร้ำง Object DecimalFormat
example : DecimalFormat decimal_format = new DecimalFormat ();
new DecimalFormat ( pattern )
method : new DecimalFormat ( pattern );
return type : DecimalFormat
content : ใช้สร้ำง Object DecimalFormat โดยมีกำรกำหนดรูปแบบของกำรแสดงผลไว้ดวย
้
example : String pattern = new String ( "#,###.00" );
DecimalFormat decimal_format = new DecimalFormat ( pattern );
:: new DecimalFormat ( pattern, object_decimalformatsymbols )

method : new DecimalFormat ( pattern,
object_decimalformatsymbols );
return type : DecimalFormat
content : ใช้สร้ำง Object DecimalFormat โดยมีกำรกำหนดรูปแบบของกำรแสดงผลไว้
ด้วย
example : String pattern = new String ( "#,###.00" );
DecimalFormatSymbols decimal_format_symbols = new
DecimalFormatSymbols ();
DecimalFormat decimal_format = new DecimalFormat (
pattern, decimal_format_symbols );
DecimalFormat Class :: applyPattern()
method : applyPattern ( pattern );
return type : void
content : ใช้กำหนดรูปแบบของกำรแสดงผล ให้กบ Object DecimalFormat
ั
example : String pattern = new String ( "#,###.00" );
DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols ();
decimal_format_symbols.applyPattern ( pattern );
DecimalFormat Class :: applyLocalizedPattern()

method : applyLocalizedPattern (
pattern );
return type : void
content : ใช้กำหนดรูปแบบของกำรแสดงผล ให้กบ Object
ั
DecimalFormat
example : String pattern = new String (
"#,###.00" );
DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols ();
decimal_format_symbols.applyLocalizedPatt
ern ( pattern );
DecimalFormat Class :: setDecimalFormatSymbols()
method : setDecimalFormatSymbols (
object_decimalformatsymbols );
return type : void
content : ใช้กำหนดรูปแบบของกำรแสดงผล ให้กบ Object DecimalFormat โดยกำหนดใน
ั
ลักษณะของ Object DecimalFormatSymbols
example : DecimalFormatSymbols decimal_format_symbols = new
DecimalFormatSymbols ();
DecimalFormat decimal_format = new DecimalFormat ();
decimal_format.setDecimalFormatSymbols (
decimal_format_symbols );
DecimalFormat Class :: getDecimalFormatSymbols(

method : getDecimalFormatSymbols ();
return type : DecimalFormatSymbols
content : ใช้คนค่ำ กำรจัดรูปแบบของกำรแสดงผล ของ Object
ื
DecimalFormat โดยคืนค่ำในลักษณะของ Object
DecimalFormatSymbols
example : DecimalFormat decimal_format = new
DecimalFormat (); DecimalFormatSymbols
decimal_format_symbols =
decimal_format.getDecimalFormatSymbols ();
DecimalFormat Class :: format()

method : format ( number );
return type : String
่
content : ใช้คนค่ำ ตัวเลข ทีได้หลังจำกกำรจัดรูปแบบแล้ว
ื
example : String pattern = new String ( "#,###.00" );
DecimalFormat decimal_format = new DecimalFormat (
pattern ); String str_datetime = decimal_format.format (
2000000 );
Reference :: Java ::
DecimalFormatSymbols Class ::
new DecimalFormatSymbols ()

method : new DecimalFormatSymbols ();
return type : DecimalFormatSymbols
content : ใช้สร้ำง Object DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols ();
new DecimalFormatSymbols ( locale )

method : new DecimalFormatSymbols ( locale
);
return type : DecimalFormatSymbols
content : ใช้สร้ำง Object DecimalFormatSymbols โดยมีคำ
่
่
รูปแบบตัวเลข ตำม timezone ของ Locale ทีกำหนด
example : Locale locale = new Locale ( "th", "TH"
); DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols ( locale );
setDecimalSeparator()
method : setDecimalSeparator ( char );
return type : void
่
content : ใช้กำหนด สัญลักษณ์ ของกำรคันตัวเลขเมื่อมีตวเลขครบทุกๆ 3
ั
ตำแหน่ง ให้กบ Object DecimalFormatSymbols
ั
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols ();
decimal_format_symbols.setDecimalSeparat
or ( "-" );
getDecimalSeparator()

method : getDecimalSeparator ();
return type : char
่
content : ใช้คนค่ำ สัญลักษณ์ ของกำรคันตัวเลขเมื่อมีตวเลขครบทุกๆ 3
ื
ั
ตำแหน่ง ของ Object DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols (); char separator =
decimal_format_symbols.getDecimalSeparat
or ();
setMonetaryDecimalSeparator()
method : setMonetaryDecimalSeparator
( char );
return type : void
่
content : ใช้กำหนด สัญลักษณ์ ของกำรแทนเครืองหมำยจุดทศนิยม ให้กบ
ั
Object DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols ();
decimal_format_symbols.setMonetaryDecim
alSeparator ( "#" );
getMonetaryDecimalSeparator()
method : getMonetaryDecimalSeparator
();
return type : char
่
content : ใช้คนค่ำ สัญลักษณ์ ของกำรแทนเครืองหมำยจุดทศนิยม ของ
ื
Object DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols (); char
monetary_separator =
decimal_format_symbols.getMonetaryDecimal
Separator ();
setPercent()
method : setPercent ( char );
return type : void
่
content : ใช้กำหนด สัญลักษณ์ ของกำรแทนเครืองหมำยเปอร์เซ็นต์ ให้กบ
ั
Object DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols ();
decimal_format_symbols.setPercent ( "#" );
getPercent()

method : getPercent ();
return type : char
่
content : ใช้คนค่ำ สัญลักษณ์ ของกำรแทนเครืองหมำยเปอร์เซ็นต์ ของ
ื
Object DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols (); char percent =
decimal_format_symbols.getPercent ();
setDigit()
method : setDigit ( char );
return type : void
content : ใช้กำหนด สัญลักษณ์ ของกำรแทนตัวเลข 0 ของเลขฐำน 2 ให้กบ
ั
Object DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols ();
decimal_format_symbols.setDigit ( "@" );
getDigit()
method : getDigit ();
return type : char
content : ใช้คนค่ำ สัญลักษณ์ ของกำรแทนตัวเลข 0 ของเลขฐำน 2 ของ Object
ื
DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols (); char digit =
decimal_format_symbols.getDigit ();
setMinusSign()
method : setMinusSign ( char );
return type : void
่
content : ใช้กำหนด สัญลักษณ์ ของกำรแทนเครืองหมำย ลบ ให้กบ
ั
Object DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols ();
decimal_format_symbols.setMinusSign ( "$" );
getMinusSign()
method : getMinusSign ();
return type : char
่
content : ใช้คนค่ำ สัญลักษณ์ ของกำรแทนเครืองหมำย ลบ ของ Object
ื
DecimalFormatSymbols
example : DecimalFormatSymbols
decimal_format_symbols = new
DecimalFormatSymbols (); char minus_sign =
decimal_format_symbols.getMinusSign ();
Reference :: Java :: MessageFormat Class ::
new MessageFormat ( pattern )

method : new MessageFormat (
object_string_pattern );
return type : MessageFormat
content : ใช้สร้ำง Object MessageFormat โดยมีกำร
่ ้
กำหนดรูปแบบของข้อควำมทีตองกำรจัดไว้ดวย
้
example : String pattern = new String (
"{0}" ); MessageFormat message_format =
new MessageFormat ( pattern );
new MessageFormat ( pattern, locale )

method : new MessageFormat ( pattern,
locale );
return type : MessageFormat
content : ใช้สร้ำง Object MessageFormat โดยมีกำรกำหนด
่ ้
รูปแบบของข้อควำมทีตองกำรจัดไว้ดวย
้
example : String pattern = new String ( "{0}" );
Locale locale = new Locale ( "th", "TH" );
MessageFormat message_format = new
MessageFormat ( pattern, locale );
applyPattern()
method : applyPattern ( pattern );
return type : void
่ ้
content : ใช้กำหนดรูปแบบของข้อควำมทีตองกำรจัด ให้กบ Object
ั
MessageFormat
example : String pattern = new String ( "{0}"
); MessageFormat message_format = new
MessageFormat ();
message_format.applyPattern ( pattern
setLocale()
method : setLocale ( object_locale );
return type : void
content : ใช้กำหนด object Locale ให้กบ Object
ั
MessageFormat
example : Locale locale = new Locale ( "th", "TH"
); MessageFormat message_format = new
MessageFormat (); message_format.setLocale
( locale );
getLocale()

method : getLocale ();
return type : Locale
content : ใช้คนค่ำ object Locale ของ Object
ื
MessageFormat
example : MessageFormat message_format =
new MessageFormat (); Locale locale =
message_format.getLocale ();
format ( object_array )

method : format ( object_array );
return type : String
่
content : ใช้คนค่ำ ข้อควำม ทีได้หลังจำกกำรจัดรูปแบบแล้ว
ื
example : MessageFormat message_format
= new MessageFormat ( "{1} explain about
{0}." ); String [] str_data = { "JAVA-SWING",
"E-Learning :: " }; String data_format =
message_format.format ( str_data );
format ( pattern, object_array )
method : format ( pattern, object_array );
return type : String
special : static
่
content : ใช้คนค่ำ ข้อควำม ทีได้หลังจำกกำรจัดรูปแบบแล้ว
ื
example : String [] str_data = { "JAVASWING", "E-Learning :: ", new Date () }; String
pattern = new String ( "{1} explain about {0}.
update-time {3, date, full}" ); String
data_format = MessageFormat.format (
pattern, str_data );
โครงสร้างของ Pattern ของการจัดรูปแบบ
subject : โครงสร้างของ Pattern ของการจัดรูปแบบ
content : โครงสร้ำงของ Pattern ของกำรจัดรูปแบบ ได้แก่ { index
} เป็ นกำรนำข้อควำมจำกดัชนีทกำหนดมำแสดง { index, type_var } เป็ น
ี่
่
กำรนำข้อควำมจำกดัชนีทกำหนดมำแสดง โดยแสดงเป็ นชนิดข้อมูลทีกำหนด { index,
ี่
่ี
type_var, kind } เป็ นกำรนำข้อควำมจำกดัชนีทกำหนดมำแสดง โดยแสดง
่
่
เป็ นชนิดข้อมูลทีกำหนด ตำมรูปแบบทีกำหนด
Reference :: Java :: Operator ::
ตัวดาเนินการทางคณิตศาสตร์
subject : ตัวดาเนินการทางคณิตศาสตร์
่
content : ตัวดำเนินกำรทำงคณิตศำสตร์ ทีใช้ใน
JAVA ได้แก่ + ( บวก ) - ( ลบ ) * ( คูณ ) / (
หำร ) % ( หำร เอำค่ำ เศษ )
ตัวดาเนินการการกาหนดค่า
subject : ตัวดาเนินการการกาหนดค่า
่
content : ตัวดำเนินกำรกำรกำหนดค่ำ ทีใช้ใน JAVA ได้แก่ = ( เช่น num
= 5 มีคำ num = 5 ) += ( เช่น num += 5 มีคำ num = num
่
่
+ 5 ) -= ( เช่น num -= 5 มีคำ num = num - 5 ) *= ( เช่น
่
num *= 5 มีคำ num = num * 5 ) /= ( เช่น num /= 5 มีคำ
่
่
num = num / 5 ) %= ( เช่น num %= 5 มีคำ num = num
่
%5)
่
ตัวดาเนินการเพิมค่าหรือลดค่า

่
subject : ตัวดาเนินการเพิมค่าหรือลดค่า
่
content : ตัวดำเนินกำรเพิ่มค่ำหรือลดค่ำ ทีใช้ใน JAVA ได้แก่ ++ตัวแปร
คือ กำรเพิ่มค่ำตัวแปรขึ้น 1 ก่อน แล้วจึงค่อยคืนค่ำ ตัวแปร++ คือ คืนค่ำตัวแปรก่อน
แล้วจึงค่อยเพิ่มค่ำตัวแปรขึ้น 1 --ตัวแปร คือ กำรลดค่ำตัวแปรลง 1 ก่อน แล้วจึงค่อยคืน
ค่ำ ตัวแปร-- คือ คืนค่ำตัวแปรก่อน แล้วจึงค่อยลดค่ำตัวแปรลง 1
ตัวดาเนินการเชิงเปรียบเทียบ

subject : ตัวดาเนินการเชิงเปรียบเทียบ
่
content : ตัวดำเนินกำรเชิงเปรียบเทียบ ทีใช้ใน JAVA ได้แก่ == (
เท่ำกับ ) != ( ไม่เท่ำกับ ) > ( มำกกว่ำ ) >= ( มำกกว่ำหรือเท่ำกับ ) < ( น้อยกว่ำ )
<= ( น้อยกว่ำหรือเท่ำกั
Reference :: Java :: Structure ::
่
คาสังควบคุมการทางาน IF

่
subject : คาสังควบคุมการทางาน IF
syntax : if ( condition ) { structure; }
่
content : คำสัง if คือ ใช้ตรวจสอบเงื่อนไข ถ้ำหำกว่ำเงื่อนไขเป็ นจริง ก็จะ
่ ่
ทำตำมคำสังทีกำหนด
example : int num = 100; if ( num > 100 ) {
System.out.print ( "many" ); }
่
คาสังควบคุมการทางาน IF ELSE

่
subject : คาสังควบคุมการทางาน IF ELSE
syntax : if ( condition ) { structure; } else {
structure; }
่
content : คำสัง if คือ ใช้ตรวจสอบเงื่อนไข ถ้ำหำกว่ำเงื่อนไขเป็ นจริง ก็จะทำตำม
่ ่
่ ่
คำสังทีกำหนด ส่วน else จะหมำยถึง ถ้ำไม่ตรงตำมเงื่อนไขใดๆ ให้ทำตำมคำสังทีกำหนด
ใน else
example : int num = 100; if ( num > 100 ) {
System.out.print ( "many" ); } else {
System.out.print ( "little" ); }
่
คาสังควบคุมการทางาน IF ELSE IF

่
subject : คาสังควบคุมการทางาน IF ELSE IF
syntax : if ( condition ) { structure; } else if (
condition ) { structure; } else { structure; }
่
content : คำสัง if คือ ใช้ตรวจสอบเงื่อนไข ถ้ำหำกว่ำเงื่อนไขเป็ นจริง ก็จะทำ
่ ่
่
ตำมคำสังทีกำหนด ส่วน else จะหมำยถึง ถ้ำไม่ตรงตำมเงื่อนไขใดๆ ให้ทำตำมคำสัง
่
ทีกำหนดใน else
example : int num = 100; if ( num > 100 ) {
System.out.print ( "many" ); } else if ( num >
50 ) { System.out.print ( "middle" ); } else {
System.out.print ( "little" ); }
่
คาสังควบคุมการทางาน NESTED IF
่
subject : คาสังควบคุมการทางาน NESTED IF
syntax : if ( condition ) { if ( condition ) {
structure; } }
่
content : คำสัง if คือ ใช้ตรวจสอบเงื่อนไข ถ้ำหำกว่ำเงื่อนไขเป็ นจริง ก็จะทำ
่ ่
่
ตำมคำสังทีกำหนด ส่วน else จะหมำยถึง ถ้ำไม่ตรงตำมเงื่อนไขใดๆ ให้ทำตำมคำสังที่
กำหนดใน else
example : int num = 100; if ( num > 100 ) {
System.out.print ( "many" ); if ( num > 50 ) {
System.out.print ( "middle" ); } }
่
คาสังควบคุมการทางาน SWITCH CASE
่
subject : คาสังควบคุมการทางาน SWITCH CASE
syntax : switch ( variable ) { case value_1 :
structure; break; case value_2 : structure;
break; default : structure; break; }
่
content : คำสัง switch case คือ จะตรวจสอบค่ำของตัวแปร ถ้ำตรง
่ ้
่
ตำมเงื่อนไขใดก็จะทำตำมคำสังนันๆ จนกว่ำจะเจอ คำสัง break
example : int num = 100; switch ( num ) { case
100 : System.out.print ( "many" ); break; case
50 : System.out.print ( "middle" ); break;
default : System.out.print ( "little" ); break; }
 Reference :: Java :: เต็ม

Reference :: Java :: เต็ม

  • 1.
  • 2.
    จัดทำโดย นำยจิตติ เจริญศิลป์ เลขที่5 สทส.1/1 นำยอนิวรรต หนิ้วบุรุษ เลขที่ 7 สทส.1/1 นำยภูมิรพี สัทธินทรีย์ เลขที่ 12 สทส.1/1
  • 3.
    Reference :: Java:: DecimalFormat Class ::
  • 4.
    :: new DecimalFormat() method : new DecimalFormat (); return type : DecimalFormat content : ใช้สร้ำง Object DecimalFormat example : DecimalFormat decimal_format = new DecimalFormat ();
  • 5.
    new DecimalFormat (pattern ) method : new DecimalFormat ( pattern ); return type : DecimalFormat content : ใช้สร้ำง Object DecimalFormat โดยมีกำรกำหนดรูปแบบของกำรแสดงผลไว้ดวย ้ example : String pattern = new String ( "#,###.00" ); DecimalFormat decimal_format = new DecimalFormat ( pattern );
  • 6.
    :: new DecimalFormat( pattern, object_decimalformatsymbols ) method : new DecimalFormat ( pattern, object_decimalformatsymbols ); return type : DecimalFormat content : ใช้สร้ำง Object DecimalFormat โดยมีกำรกำหนดรูปแบบของกำรแสดงผลไว้ ด้วย example : String pattern = new String ( "#,###.00" ); DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); DecimalFormat decimal_format = new DecimalFormat ( pattern, decimal_format_symbols );
  • 7.
    DecimalFormat Class ::applyPattern() method : applyPattern ( pattern ); return type : void content : ใช้กำหนดรูปแบบของกำรแสดงผล ให้กบ Object DecimalFormat ั example : String pattern = new String ( "#,###.00" ); DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); decimal_format_symbols.applyPattern ( pattern );
  • 8.
    DecimalFormat Class ::applyLocalizedPattern() method : applyLocalizedPattern ( pattern ); return type : void content : ใช้กำหนดรูปแบบของกำรแสดงผล ให้กบ Object ั DecimalFormat example : String pattern = new String ( "#,###.00" ); DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); decimal_format_symbols.applyLocalizedPatt ern ( pattern );
  • 9.
    DecimalFormat Class ::setDecimalFormatSymbols() method : setDecimalFormatSymbols ( object_decimalformatsymbols ); return type : void content : ใช้กำหนดรูปแบบของกำรแสดงผล ให้กบ Object DecimalFormat โดยกำหนดใน ั ลักษณะของ Object DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); DecimalFormat decimal_format = new DecimalFormat (); decimal_format.setDecimalFormatSymbols ( decimal_format_symbols );
  • 10.
    DecimalFormat Class ::getDecimalFormatSymbols( method : getDecimalFormatSymbols (); return type : DecimalFormatSymbols content : ใช้คนค่ำ กำรจัดรูปแบบของกำรแสดงผล ของ Object ื DecimalFormat โดยคืนค่ำในลักษณะของ Object DecimalFormatSymbols example : DecimalFormat decimal_format = new DecimalFormat (); DecimalFormatSymbols decimal_format_symbols = decimal_format.getDecimalFormatSymbols ();
  • 11.
    DecimalFormat Class ::format() method : format ( number ); return type : String ่ content : ใช้คนค่ำ ตัวเลข ทีได้หลังจำกกำรจัดรูปแบบแล้ว ื example : String pattern = new String ( "#,###.00" ); DecimalFormat decimal_format = new DecimalFormat ( pattern ); String str_datetime = decimal_format.format ( 2000000 );
  • 12.
    Reference :: Java:: DecimalFormatSymbols Class ::
  • 13.
    new DecimalFormatSymbols () method: new DecimalFormatSymbols (); return type : DecimalFormatSymbols content : ใช้สร้ำง Object DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols ();
  • 14.
    new DecimalFormatSymbols (locale ) method : new DecimalFormatSymbols ( locale ); return type : DecimalFormatSymbols content : ใช้สร้ำง Object DecimalFormatSymbols โดยมีคำ ่ ่ รูปแบบตัวเลข ตำม timezone ของ Locale ทีกำหนด example : Locale locale = new Locale ( "th", "TH" ); DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols ( locale );
  • 15.
    setDecimalSeparator() method : setDecimalSeparator( char ); return type : void ่ content : ใช้กำหนด สัญลักษณ์ ของกำรคันตัวเลขเมื่อมีตวเลขครบทุกๆ 3 ั ตำแหน่ง ให้กบ Object DecimalFormatSymbols ั example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); decimal_format_symbols.setDecimalSeparat or ( "-" );
  • 16.
    getDecimalSeparator() method : getDecimalSeparator(); return type : char ่ content : ใช้คนค่ำ สัญลักษณ์ ของกำรคันตัวเลขเมื่อมีตวเลขครบทุกๆ 3 ื ั ตำแหน่ง ของ Object DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); char separator = decimal_format_symbols.getDecimalSeparat or ();
  • 17.
    setMonetaryDecimalSeparator() method : setMonetaryDecimalSeparator (char ); return type : void ่ content : ใช้กำหนด สัญลักษณ์ ของกำรแทนเครืองหมำยจุดทศนิยม ให้กบ ั Object DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); decimal_format_symbols.setMonetaryDecim alSeparator ( "#" );
  • 18.
    getMonetaryDecimalSeparator() method : getMonetaryDecimalSeparator (); returntype : char ่ content : ใช้คนค่ำ สัญลักษณ์ ของกำรแทนเครืองหมำยจุดทศนิยม ของ ื Object DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); char monetary_separator = decimal_format_symbols.getMonetaryDecimal Separator ();
  • 19.
    setPercent() method : setPercent( char ); return type : void ่ content : ใช้กำหนด สัญลักษณ์ ของกำรแทนเครืองหมำยเปอร์เซ็นต์ ให้กบ ั Object DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); decimal_format_symbols.setPercent ( "#" );
  • 20.
    getPercent() method : getPercent(); return type : char ่ content : ใช้คนค่ำ สัญลักษณ์ ของกำรแทนเครืองหมำยเปอร์เซ็นต์ ของ ื Object DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); char percent = decimal_format_symbols.getPercent ();
  • 21.
    setDigit() method : setDigit( char ); return type : void content : ใช้กำหนด สัญลักษณ์ ของกำรแทนตัวเลข 0 ของเลขฐำน 2 ให้กบ ั Object DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); decimal_format_symbols.setDigit ( "@" );
  • 22.
    getDigit() method : getDigit(); return type : char content : ใช้คนค่ำ สัญลักษณ์ ของกำรแทนตัวเลข 0 ของเลขฐำน 2 ของ Object ื DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); char digit = decimal_format_symbols.getDigit ();
  • 23.
    setMinusSign() method : setMinusSign( char ); return type : void ่ content : ใช้กำหนด สัญลักษณ์ ของกำรแทนเครืองหมำย ลบ ให้กบ ั Object DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); decimal_format_symbols.setMinusSign ( "$" );
  • 24.
    getMinusSign() method : getMinusSign(); return type : char ่ content : ใช้คนค่ำ สัญลักษณ์ ของกำรแทนเครืองหมำย ลบ ของ Object ื DecimalFormatSymbols example : DecimalFormatSymbols decimal_format_symbols = new DecimalFormatSymbols (); char minus_sign = decimal_format_symbols.getMinusSign ();
  • 25.
    Reference :: Java:: MessageFormat Class ::
  • 26.
    new MessageFormat (pattern ) method : new MessageFormat ( object_string_pattern ); return type : MessageFormat content : ใช้สร้ำง Object MessageFormat โดยมีกำร ่ ้ กำหนดรูปแบบของข้อควำมทีตองกำรจัดไว้ดวย ้ example : String pattern = new String ( "{0}" ); MessageFormat message_format = new MessageFormat ( pattern );
  • 27.
    new MessageFormat (pattern, locale ) method : new MessageFormat ( pattern, locale ); return type : MessageFormat content : ใช้สร้ำง Object MessageFormat โดยมีกำรกำหนด ่ ้ รูปแบบของข้อควำมทีตองกำรจัดไว้ดวย ้ example : String pattern = new String ( "{0}" ); Locale locale = new Locale ( "th", "TH" ); MessageFormat message_format = new MessageFormat ( pattern, locale );
  • 28.
    applyPattern() method : applyPattern( pattern ); return type : void ่ ้ content : ใช้กำหนดรูปแบบของข้อควำมทีตองกำรจัด ให้กบ Object ั MessageFormat example : String pattern = new String ( "{0}" ); MessageFormat message_format = new MessageFormat (); message_format.applyPattern ( pattern
  • 29.
    setLocale() method : setLocale( object_locale ); return type : void content : ใช้กำหนด object Locale ให้กบ Object ั MessageFormat example : Locale locale = new Locale ( "th", "TH" ); MessageFormat message_format = new MessageFormat (); message_format.setLocale ( locale );
  • 30.
    getLocale() method : getLocale(); return type : Locale content : ใช้คนค่ำ object Locale ของ Object ื MessageFormat example : MessageFormat message_format = new MessageFormat (); Locale locale = message_format.getLocale ();
  • 31.
    format ( object_array) method : format ( object_array ); return type : String ่ content : ใช้คนค่ำ ข้อควำม ทีได้หลังจำกกำรจัดรูปแบบแล้ว ื example : MessageFormat message_format = new MessageFormat ( "{1} explain about {0}." ); String [] str_data = { "JAVA-SWING", "E-Learning :: " }; String data_format = message_format.format ( str_data );
  • 32.
    format ( pattern,object_array ) method : format ( pattern, object_array ); return type : String special : static ่ content : ใช้คนค่ำ ข้อควำม ทีได้หลังจำกกำรจัดรูปแบบแล้ว ื example : String [] str_data = { "JAVASWING", "E-Learning :: ", new Date () }; String pattern = new String ( "{1} explain about {0}. update-time {3, date, full}" ); String data_format = MessageFormat.format ( pattern, str_data );
  • 33.
    โครงสร้างของ Pattern ของการจัดรูปแบบ subject: โครงสร้างของ Pattern ของการจัดรูปแบบ content : โครงสร้ำงของ Pattern ของกำรจัดรูปแบบ ได้แก่ { index } เป็ นกำรนำข้อควำมจำกดัชนีทกำหนดมำแสดง { index, type_var } เป็ น ี่ ่ กำรนำข้อควำมจำกดัชนีทกำหนดมำแสดง โดยแสดงเป็ นชนิดข้อมูลทีกำหนด { index, ี่ ่ี type_var, kind } เป็ นกำรนำข้อควำมจำกดัชนีทกำหนดมำแสดง โดยแสดง ่ ่ เป็ นชนิดข้อมูลทีกำหนด ตำมรูปแบบทีกำหนด
  • 34.
    Reference :: Java:: Operator ::
  • 35.
    ตัวดาเนินการทางคณิตศาสตร์ subject : ตัวดาเนินการทางคณิตศาสตร์ ่ content: ตัวดำเนินกำรทำงคณิตศำสตร์ ทีใช้ใน JAVA ได้แก่ + ( บวก ) - ( ลบ ) * ( คูณ ) / ( หำร ) % ( หำร เอำค่ำ เศษ )
  • 36.
    ตัวดาเนินการการกาหนดค่า subject : ตัวดาเนินการการกาหนดค่า ่ content: ตัวดำเนินกำรกำรกำหนดค่ำ ทีใช้ใน JAVA ได้แก่ = ( เช่น num = 5 มีคำ num = 5 ) += ( เช่น num += 5 มีคำ num = num ่ ่ + 5 ) -= ( เช่น num -= 5 มีคำ num = num - 5 ) *= ( เช่น ่ num *= 5 มีคำ num = num * 5 ) /= ( เช่น num /= 5 มีคำ ่ ่ num = num / 5 ) %= ( เช่น num %= 5 มีคำ num = num ่ %5)
  • 37.
    ่ ตัวดาเนินการเพิมค่าหรือลดค่า ่ subject : ตัวดาเนินการเพิมค่าหรือลดค่า ่ content: ตัวดำเนินกำรเพิ่มค่ำหรือลดค่ำ ทีใช้ใน JAVA ได้แก่ ++ตัวแปร คือ กำรเพิ่มค่ำตัวแปรขึ้น 1 ก่อน แล้วจึงค่อยคืนค่ำ ตัวแปร++ คือ คืนค่ำตัวแปรก่อน แล้วจึงค่อยเพิ่มค่ำตัวแปรขึ้น 1 --ตัวแปร คือ กำรลดค่ำตัวแปรลง 1 ก่อน แล้วจึงค่อยคืน ค่ำ ตัวแปร-- คือ คืนค่ำตัวแปรก่อน แล้วจึงค่อยลดค่ำตัวแปรลง 1
  • 38.
    ตัวดาเนินการเชิงเปรียบเทียบ subject : ตัวดาเนินการเชิงเปรียบเทียบ ่ content: ตัวดำเนินกำรเชิงเปรียบเทียบ ทีใช้ใน JAVA ได้แก่ == ( เท่ำกับ ) != ( ไม่เท่ำกับ ) > ( มำกกว่ำ ) >= ( มำกกว่ำหรือเท่ำกับ ) < ( น้อยกว่ำ ) <= ( น้อยกว่ำหรือเท่ำกั
  • 39.
    Reference :: Java:: Structure ::
  • 40.
    ่ คาสังควบคุมการทางาน IF ่ subject :คาสังควบคุมการทางาน IF syntax : if ( condition ) { structure; } ่ content : คำสัง if คือ ใช้ตรวจสอบเงื่อนไข ถ้ำหำกว่ำเงื่อนไขเป็ นจริง ก็จะ ่ ่ ทำตำมคำสังทีกำหนด example : int num = 100; if ( num > 100 ) { System.out.print ( "many" ); }
  • 41.
    ่ คาสังควบคุมการทางาน IF ELSE ่ subject: คาสังควบคุมการทางาน IF ELSE syntax : if ( condition ) { structure; } else { structure; } ่ content : คำสัง if คือ ใช้ตรวจสอบเงื่อนไข ถ้ำหำกว่ำเงื่อนไขเป็ นจริง ก็จะทำตำม ่ ่ ่ ่ คำสังทีกำหนด ส่วน else จะหมำยถึง ถ้ำไม่ตรงตำมเงื่อนไขใดๆ ให้ทำตำมคำสังทีกำหนด ใน else example : int num = 100; if ( num > 100 ) { System.out.print ( "many" ); } else { System.out.print ( "little" ); }
  • 42.
    ่ คาสังควบคุมการทางาน IF ELSEIF ่ subject : คาสังควบคุมการทางาน IF ELSE IF syntax : if ( condition ) { structure; } else if ( condition ) { structure; } else { structure; } ่ content : คำสัง if คือ ใช้ตรวจสอบเงื่อนไข ถ้ำหำกว่ำเงื่อนไขเป็ นจริง ก็จะทำ ่ ่ ่ ตำมคำสังทีกำหนด ส่วน else จะหมำยถึง ถ้ำไม่ตรงตำมเงื่อนไขใดๆ ให้ทำตำมคำสัง ่ ทีกำหนดใน else example : int num = 100; if ( num > 100 ) { System.out.print ( "many" ); } else if ( num > 50 ) { System.out.print ( "middle" ); } else { System.out.print ( "little" ); }
  • 43.
    ่ คาสังควบคุมการทางาน NESTED IF ่ subject: คาสังควบคุมการทางาน NESTED IF syntax : if ( condition ) { if ( condition ) { structure; } } ่ content : คำสัง if คือ ใช้ตรวจสอบเงื่อนไข ถ้ำหำกว่ำเงื่อนไขเป็ นจริง ก็จะทำ ่ ่ ่ ตำมคำสังทีกำหนด ส่วน else จะหมำยถึง ถ้ำไม่ตรงตำมเงื่อนไขใดๆ ให้ทำตำมคำสังที่ กำหนดใน else example : int num = 100; if ( num > 100 ) { System.out.print ( "many" ); if ( num > 50 ) { System.out.print ( "middle" ); } }
  • 44.
    ่ คาสังควบคุมการทางาน SWITCH CASE ่ subject: คาสังควบคุมการทางาน SWITCH CASE syntax : switch ( variable ) { case value_1 : structure; break; case value_2 : structure; break; default : structure; break; } ่ content : คำสัง switch case คือ จะตรวจสอบค่ำของตัวแปร ถ้ำตรง ่ ้ ่ ตำมเงื่อนไขใดก็จะทำตำมคำสังนันๆ จนกว่ำจะเจอ คำสัง break example : int num = 100; switch ( num ) { case 100 : System.out.print ( "many" ); break; case 50 : System.out.print ( "middle" ); break; default : System.out.print ( "little" ); break; }