619
1了解Java 什么是Java Java的特性 如何学习Java

Java Jdk6学习笔记[Ppt]

Embed Size (px)

DESCRIPTION

 

Citation preview

  • 1. 1 Java Java Java Java
  • 2. Java SunGreenProjectStar7 JamesGoslingOak JavaApplet 1995/5/23Java DevelopmentKits JDK1.0a2
  • 3. Java JavaObject-Oriented Java DevelopmentKitsJDK J2SE 5.0Java 2 Platform Standard Edition5.0JDKJ2SE Development Kit 5.0
  • 4. Java J2SE 5.0Java 2 Platform Standard Edition5.0JDKJ2SE Development Kit 5.0 JavaSE 6Java Platform, Standard Edition6JDK6Java SE Development Kit 6 261.6.0 6productversion1.6.0 developerversion
  • 5. Java Simple Object-oriented Network-savvy Interpreted Robust Secure Portable High-performance
  • 6. Java Java SE Java Platform, Standard Edition Java EE Java Platform, Enterprise Edition Java ME Java Platform, Micro Edition
  • 7. Java Platform, Standard Edition (Java SE) Java
  • 8. Java Platform, Standard Edition (Java SE) JVM JavaJava Virtual Machine,JVM JRE JavaJava SE Runtime Environment,JRE JDK Java
  • 9. Java Platform, Enterprise Edition (Java EE) JavaSE API Multi- tieredWeb JSPServletEnterprise JavaBeansEJBJava Remote Method InvocationRMI
  • 10. Java Platform, Micro Edition (Java ME) PDA
  • 11.
  • 12. Java Java JavaSE API ContainerI/O Thread http://java.sun.com/javase/6/docs/api/inde x.html
  • 13. Java http://www.google.com/ http://www.javaworld.com.tw/ http://java.sun.com/developer/onlineTraining/n ew2java/javamap/intro.html
  • 14. 2 JDK PathClasspath Java
  • 15. JDK JDK620061211 Update http://java.sun.com/javase/downloads/inde x.jsp
  • 16. JDK JRE
  • 17. JDK
  • 18. JDK JRE JDKJRE JDKjre JDKJREJRE serverVMVirtualMachine
  • 19. JDK JDKJREserver
  • 20. JDK JDK bin JDK demo jre JDKJRE db ApacheDerbyJava
  • 21. JDK JDK lib Java JDKJava bin Wrapper javac.exelib tools.jar
  • 22. JDK JDK src.zip JavaAPI
  • 23. Path javac Path
  • 24. Path Path set Path= C:Program FilesJavajdk1.6.0bin;%Path% WindowsJREjava.exe C:WindowsSystem32 Path
  • 25. Classpath Java Java Path Windows exe ClasspathJava JavaJVM class
  • 26. Classpath JDK6JDK libJava javac -classpath classpath1;classpath2 WindowsPath .exe JavaClassPath JVM".class"
  • 27. Java
  • 28. Java HelloJava.java
  • 29. Java Java.java Tab
  • 30. Java javac HelloJava.java error: cannot read: HelloJava.java javac.java HelloJava.java:1: class HelloJava is public, should be declared in a file named HellJava.java
  • 31. Java HelloJava.java:3: cannot find symbol javac PathPathJDK bin
  • 32. Java java HelloJava Exception inthread"main" java.lang.NoClassDefFoundError java Exceptionin thread "main" java.lan.NosuchMethodError: main JavaEntrypointjava main(String[] args)method
  • 33. UltraEdithttp://www.ultraedit.com/ Editplushttp://www.editplus.com/ JCreaterhttp://www.jcreator.com/ BlueJhttp://www.bluej.org/index.html IDE Eclipsehttp://www.eclipse.org/ NetBeanshttp://www.netbeans.org/
  • 34. 3 Java
  • 35. Java Class Block main()Method Statement public class HelloJava { public static void main(String[] args) { System.out.println("Java"); } }
  • 36. CJava Cprintf() public class HelloJavaForC { public static void main(String[] args) { System.out.printf("%s Javan", "CFan"); } } System.out.printf("%s Java", "CFan").println(); System.out.printf("%s %d Javan", "CFan", 3);
  • 37. /* * printf() * 2005/4/30 */ public class ThirdJavaForC { public static void main(String[] args) { // printf()J2SE5.0JDK5.0 System.out.printf("%s %dJavan", "CFan", 3); } }
  • 38. /*1blabla /* 2blabla */ */ /*1blabla //2blabla */
  • 39. Scanner J2SE 5.0java.util.Scanner Scanner scanner = new Scanner(System.in); System.out.print(""); System.out.printf("%s!n", scanner.next()); next() System.out.print(""); System.out.printf("%dn", scanner.nextInt());
  • 40. BufferedReader BufferedReaderjava.io.Reader java.io.InputStreamReader BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(System.in)); System.out.print(": "); String text = bufferedReader.readLine(); System.out.println(": " + text);
  • 41. Systemout Stream java HelloJava > HelloJavaResult.txt Systemin
  • 42. err err err System.out.println("out"); System.err.println("err"); java ErrDemo > ErrDemoResult.txt err
  • 43. ' ' " " uxxxx 16Unicode xxx 8Unicode b f n r t (Tab) System.out.println("u0048u0065u006Cu006Cu006F");
  • 44. J2SE5.0 //19 System.out.printf("%d%n", 19); //19 System.out.printf("%o%n", 19); //19 System.out.printf("%x%n", 19);
  • 45. %% % %d 10ByteShort IntegerLong BigInteger %f 10FloatDouble BigDecimal %e, %E 10Float DoubleBigDecimal %a, %A 1610 FloatDoubleBigDecimal %o 8ByteShort IntegerLong BigInteger %x, %X 16ByteShort Integer LongBigInteger %s, %S %c, %C ByteShortCharacter Integer %b, %B "true""false""TRUE""FALSE" %B)null "true"null"false" %t, %T /API
  • 46. System.out.printf("example:%.2f%n", 19.234); example:19.23 System.out.printf("example:%6.2f%n", 19.234); example: 19.23
  • 47. Primitivetype short2 int4 long8 float4 double8
  • 48. Primitivetype Unicode 128ASCII 'u0000''uFFFF' 2 truefalse
  • 49. Primitivetype System.out.printf("short t%d ~ %dn", Short.MAX_VALUE,Short.MIN_VALUE); System.out.printf("int t%d ~ %dn", Integer.MAX_VALUE, Integer.MIN_VALUE); System.out.printf("long t%d ~ %dn", Long.MAX_VALUE, Long.MIN_VALUE); System.out.printf("byte t%d ~ %dn", Byte.MAX_VALUE, Byte.MIN_VALUE); System.out.printf("float t%e ~ %en", Float.MAX_VALUE, Float.MIN_VALUE); System.out.printf("double t%e ~ %en", Double.MAX_VALUE, Double.MIN_VALUE);
  • 50. Java int age; // double scope; // intfloatdoublechar *&^% Java
  • 51. int ageOfStudent; int ageOfTeacher; variable var might not have been initialized
  • 52. '=' int ageOfStudent = 5; double scoreOfStudent = 80.0; char levelOfStudent = 'B'; System.out.println("tt"); System.out.printf("%4dt %4.1ft %4c", ageOfStudent, scoreOfStudent, levelOfStudent);
  • 53. final final int maxNum = 10; maxNum = 20; cannot assign a value to final variable maxNum
  • 54. +-*/ % System.out.println(1 + 2 * 3); System.out.println(1+2+3 / 4); System.out.println((double)(1+2+3) / 4);
  • 55. int testNumber = 10; System.out.println(testNumber / 3); int testNumber = 10; System.out.println(testNumber / 3.0); System.out.println((double) testNumber / 3);
  • 56. int testInteger = 0; double testDouble = 3.14; testInteger = testDouble; System.out.println(testInteger); possible loss of precision found : double required: int testInteger = testDouble ^ 1 error
  • 57. testInteger =(int) testDouble; '%' count = (count + 1) % 360;
  • 58. >>=< 5)); System.out.println("10 >= 5" + (10 >= 5)); System.out.println("10 < 5" + (10 < 5)); System.out.println("10