พื้นฐานภาษาจาวา

27
พื้นฐานภาษาจาวา พื้นฐานภาษาจาวา

Upload: jk133

Post on 25-Jun-2015

2.029 views

Category:

Education


0 download

TRANSCRIPT

  • 1.

2. Dr.Jame Gosling Sun Microsystems (Oak) 0 (Java) 3. 1) (OOP: Object Oriented Programming) 2) Java platform independence % java % 3) Free Open Source 4. Java 1. Structure 1.1 Comment Source code - comment // comment //comment comment - comment /* comment : */ /* Comment Comment */ 5. 1.2 Keyword Java : class,boolean,char 1.3 Identifiers : : method , class , ,_,$ : : 6. Java 1) Java Application Java 2) Java Applets Java HTML Web Browser Utilities Java 7. 1.4 Separators ! - () 1. method parameter private void hello( ); 2. if ,while,for ,do if ( i=0 ) 3. casting String a=( String )x; 8. - [ ] 1. Array String a[ ]; 2. index array a[ 0 ]=10; - ; String a ; - , 1. String a , b , c; - . 1. package,subpackage class package com.test.Test1; 2. method Object object.hello(); 9. - { } method class class A{ } Private void hello(){ } 2. Array String a[]={"A","B","C"}; 10. : Scanner : Scanner keyboard; keyboard Scanner : new : = new ( ); 11. keyboard ! ! System.in ! keyboard = new Scanner(System.in); Scanner ! ! 12. nextByte() nextDouble() nextFloat() nextInt() nextLine() nextLong() nextShort() Byte Double Float Int Long Short 13. int number; Scanner keyboard = new Scanner(System.in); System.out.print(Enter an integer value: ); number = keyboard.nextInt(); 14. import import import Scanner : import java.util.Scanner Scanner util util : java 15. (Operators) (Arithmetic Operators) : : 16. Operator "*"(Multiply)1"/" (Divide)2"%" (Modulus)3"+" (Add)4"-" (Minus)op1-op1:5 17. class BasicMath{ public static void main (String args[]){ int a = 1 + 1; int b = a * 3; int c = b / 4; int d = b " a; int e = -d; int f = 9%5; System.out.println("a = " + a); System.out.println("b = " + b); System.out.println("c = " + c); System.out.println("e = " + e); System.out.println("9%5 = " + 9%5); } } 18. (Relational Operators) (Boolean) 19. Relational Operator =7); //a ==Op1==Op2 : Op1 Op2a=(5==7); // a 5 7!=Op1!=Op2 : Op1 Op2a=(5!=7); // a 5 7":(expression)"a:b : operand a expression a=(3>5)"false:true; //a 3 5 true 20. (Logical Operators) Boolean % 21. 1 2 AND OR XORtrue 1true 1true 1true 1false 0true 1false 0false 0true 1true 1false 0true 1false 0true 1true 1false 0false 0false 0false 0false 0 22. Boolean Operator Operator ! (NOT)!(Op1) a= !(true); // a && (AND)Op1 && Op2 Op1 a= !(true && false); // a Op2|| (OR)Op1 || Op2 Op1 a= !(true); // a Op2 23. String String Class Package java.lang character 1 : : 1 String : Class String : String Class 24. Object String 6 1 String Object = new String( ); 2 String Object = ; 3 String (char chars[]); String Array Chars String 25. 4 String (char chars[], int startIndex, int numChars); Array String startIndex array numChars startIndex 26. 5 String (String); String String String String 6 Array ASCII String - String (byte asciiChars[]); 27. http://www.sourcecode.in.th/lession.php?no=14&group=3 https://sites.google.com/site/javabasiceaw/home http://java2see.blogspot.com/2009/08/java-java-structure.html 2 2009/08/