Java Programming/Print Version - Wikibooks, Open Books for an Open World
Total Page:16
File Type:pdf, Size:1020Kb
Java Programming/Print version - Wikibooks, open books for an open worldhttps://en.wikibooks.org/w/index.php?title=Java_Programming/Print_ve... Java Programming/Print version Contents 1 Overview 2 Preface 2.1 Are you new to programming? 2.2 Programming with Java™ 2.3 What can Java not do? 3 About This Book 3.1 Who should read this book? 3.2 How to use this book 3.3 How can you participate 3.3.1 As a reader 3.3.2 As a contributor 4 History 4.1 Earlier programming languages 4.2 The Green team 4.3 Reshaping thought 4.4 The demise of an idea, birth of another 4.5 Versions 4.5.1 Initial Release (versions 1.0 and 1.1) 4.5.2 Java 2 (version 1.2) 4.5.3 Kestrel (Java 1.3) 4.5.4 Merlin (Java 1.4) 4.5.5 Tiger (version 1.5.0; Java SE 5) 4.5.6 Mustang (version 1.6.0; Java SE 6) 4.5.7 Dolphin (version 1.7.0; Java SE 7) 4.6 References 5 Java Overview 5.1 Object orientation 5.2 Platform dependence 5.3 Standardization 5.4 Secure execution 5.5 Error handling 5.6 Networking capabilities 5.7 Dynamic class loading 5.8 Automatic memory garbage collection 5.9 Applet 5.10 Forbidden bad practices 5.11 Evaluation 6 The Java Platform 6.1 Java Runtime Environment (JRE) 6.1.1 Executing native Java code (or byte-code) 6.1.2 Do you have a JRE? 6.1.3 Java Virtual Machine (JVM) 6.1.3.1 Just-in-Time Compilation 6.1.3.2 Native optimization 6.1.3.3 Was JVM the first virtual machine? 6.2 Java Development Kit (JDK) 6.2.1 The Java compiler 6.2.2 Applet development 6.2.3 Annotation processing 6.2.4 Integration of non-Java and Java code 6.2.5 Class library conflicts 6.2.6 Software security and cryptography tools 6.2.7 The Java archiver 6.2.8 The Java debugger 6.2.9 Documenting code with Java 6.2.10 The native2ascii tool 6.2.11 Remote Method Invocation (RMI) tools 6.2.12 Java IDL and RMI-IIOP Tools 6.2.13 Deployment & Web Start Tools 6.2.14 Browser Plug-In Tools 6.2.15 Monitoring and Management Tools / Troubleshooting Tools 6.2.16 Java class libraries (JCL) 6.3 Similar concepts 6.3.1 The .NET framework 6.3.2 Third-party compilers targeting the JVM 7 Getting started 7.1 Understanding systems 7.2 The process of abstraction 7.2.1 Thinking in objects 7.2.2 Understanding class definitions and types 7.2.3 Expanding your class definitions 7.2.4 Adding behavior to objects 7.3 The process of encapsulation 7.3.1 Using access modifiers 8 Installation 8.1 Availability check for JRE 8.2 Availability check for JDK 1 sur 134 30/01/2016 20:09 Java Programming/Print version - Wikibooks, open books for an open worldhttps://en.wikibooks.org/w/index.php?title=Java_Programming/Print_ve... 8.3 Advanced availability check options on Windows platform 8.4 Download instructions 8.5 Updating environment variables 8.6 Start writing code 8.7 Availability check for JRE 8.8 Availability check for JDK 8.9 Installation using Terminal 8.10 Download instructions 8.11 Start writing code 8.12 Updating Java for Mac OS 8.13 Availability check for JDK 9 Compilation 9.1 Quick compilation procedure 9.2 Automatic Compilation of Dependent Classes 9.3 Packages, Subdirectories, and Resources 9.3.1 Top level package 9.3.2 Subpackages 9.4 Filename Case 9.5 Compiler Options 9.5.1 Debugging and Symbolic Information 9.6 Ant 9.7 The JIT compiler 10 Execution 10.1 JSE code execution 10.2 J2EE code execution 10.3 Jini 11 Understanding a Java Program 11.1 The Distance Class: Intent, Source, and Use 11.2 Detailed Program Structure and Overview 11.2.1 Introduction to Java Syntax 11.2.2 Declarations and Definitions 11.2.2.1 Example: Instance Fields 11.2.2.2 Example: Constructor 11.2.2.3 Example: Methods 11.2.2.4 The printDistance() method 11.2.2.5 The main() method 11.2.2.6 The intValue() method 11.2.2.7 Static vs. Instance Methods 11.2.3 Data Types 11.2.3.1 Primitive Types 11.2.3.2 Reference Types 11.2.3.3 Array Types 11.2.3.4 void 11.3 Whitespace 11.3.1 Required Whitespace 11.4 Indentation 12 Java IDEs 12.1 What is a Java IDE? 12.2 Eclipse 12.3 NetBeans 12.4 JCreator 12.5 Processing 12.6 BlueJ 12.7 Kawa 12.8 JBuilder 12.9 DrJava 12.10 Other IDEs 13 Language Fundamentals 13.1 The Java programming syntax 14 Statements 14.1 Variable declaration statement 14.2 Assignment statements 14.3 Assertion 14.4 Program Control Flow 14.5 Statement Blocks 14.6 Branching Statements 14.6.1 Unconditional Branching Statements 14.7 Return statement 14.7.1 Conditional Branching Statements 14.7.1.1 Conditional Statements 14.7.1.2 If...else statements 14.7.1.3 Switch statements 14.8 Iteration Statements 14.8.1 The while loop 14.8.2 The do...while loop 14.8.3 The for loop 14.8.4 The foreach loop 14.9 The continue and break statements 14.10 Throw statement 14.11 try/catch 15 Conditional blocks 15.1 If 15.2 If/else 15.3 If/else-if/else 2 sur 134 30/01/2016 20:09 Java Programming/Print version - Wikibooks, open books for an open worldhttps://en.wikibooks.org/w/index.php?title=Java_Programming/Print_ve... 15.4 Conditional expressions 15.5 Switch 16 Loop blocks 16.1 While 16.1.1 Do... while 16.2 For 16.2.1 For-each 16.3 Break and continue keywords 16.4 Labels 16.5 Try... catch blocks 16.6 Examples 17 Boolean expressions 17.1 Comparative operators 17.2 Boolean operators 18 Variables 18.1 Variables in Java programming 18.2 Kinds of variables 18.3 Creating variables 18.4 Assigning values to variables 18.5 Grouping variable declarations and assignment operations 18.6 Identifiers 18.7 Naming conventions for identifiers 18.8 Literals (values) 19 Primitive Types 19.1 Numbers in computer science 19.2 Integer types in Java 19.3 Integer numbers and floating point numbers 19.4 Data conversion (casting) 19.5 Notes 20 Arithmetic expressions 20.1 Using bitwise operators within Java 21 Literals 21.1 Boolean Literals 21.2 Numeric Literals 21.2.1 Integer Literals 21.2.2 Floating Point Literals 21.2.3 Character Literals 21.3 String Literals 21.4 null 21.5 Mixed Mode Operations 22 Methods 22.1 Parameter passing 22.1.1 Primitive type parameter 22.1.2 Object parameter 22.2 Variable argument list 22.3 Return parameter 22.4 Special method, the constructor 22.5 Static methods 23 API/java.lang.String 23.1 Immutability 23.2 Concatenation 23.3 Using StringBuilder/StringBuffer to concatenate strings 23.4 Comparing Strings 23.5 Splitting a String 23.6 Substrings 23.7 String cases 23.8 See also 24 Classes, Objects and Types 24.1 Instantiation and constructors 24.2 Type 24.3 Autoboxing/unboxing 24.4 Methods in the Object class 24.4.1 The clone method 24.4.2 The equals method 24.4.3 The finalize method 24.4.4 The getClass method 24.4.5 The hashCode method 24.4.6 The toString method 24.4.7 The wait and notify thread signaling methods 24.4.7.1 The wait methods 24.4.7.2 The notify and notifyAll methods 25 Keywords 25.1 abstract 25.2 assert 25.3 boolean 25.4 break 25.5 byte 25.6 case 25.7 catch 25.8 char 25.9 class 25.10 const 25.11 continue 25.12 See also 3 sur 134 30/01/2016 20:09 Java Programming/Print version - Wikibooks, open books for an open worldhttps://en.wikibooks.org/w/index.php?title=Java_Programming/Print_ve... 25.13 default 25.14 do 25.15 double 25.16 else 25.17 enum 25.18 extends 25.19 final 25.20 For a variable 25.21 For a class 25.22 For a method 25.23 Interest 25.24 finally 25.25 float 25.26 for 25.27 goto 25.28 if 25.29 implements 25.30 import 25.31 instanceof 25.32 int 25.33 interface 25.34 long 25.35 native 25.36 See also 25.37 new 25.38 package 25.39 private 25.40 protected 25.41 public 25.42 return 25.43 short 25.44 static 25.45 Interest 25.46 strictfp 25.47 super 25.48 switch 25.49 synchronized 25.50 Singleton example 25.51 this 25.52 throw 25.53 throws 25.54 transient 25.55 try 25.56 void 25.57 volatile 25.58 while 26 Packages 26.1 Package declaration 26.2 Import and class usage 26.3 Wildcard imports 26.4 Package convention 26.5 Importing packages from .jar files 26.6 Class loading/package 27 Arrays 27.1 Fundamentals 27.2 Two-Dimensional Arrays 27.3 Multidimensional Array 28 Mathematical functions 28.1 Math constants 28.1.1 Math.E 28.1.2 Math.PI 28.2 Math methods 28.2.1 Exponential methods 28.2.1.1 Exponentiation 28.2.1.2 Logarithms 28.2.2 Trigonometric and hyperbolic methods 28.2.2.1 Trigonometric functions 28.2.2.2 Inverse trigonometric functions 28.2.2.3 Hyperbolic functions 28.2.2.4 Radian/degree conversion 28.2.3 Absolute value: Math.abs 28.2.4 Maximum and minimum values 28.3 Functions dealing with floating-point representation 28.4 Rounding number example 29 Large numbers 29.1 BigInteger 29.2 BigDecimal 30 Random numbers 30.1 Truly random numbers 31 Unicode 31.1 Unicode escape sequences 31.2 International language support 31.3 References 32 Comments 4 sur 134 30/01/2016 20:09 Java Programming/Print version - Wikibooks, open books for an open worldhttps://en.wikibooks.org/w/index.php?title=Java_Programming/Print_ve..