Java Notes For Professionals - Free Programming Books

Transcription

JavaJavaNotes for Professionals Notes for Professionals900 pagesof professional hints and tricksGoalKicker.comFree Programming BooksDisclaimerThis is an uno cial free book created for educational purposes and isnot a liated with o cial Java group(s) or company(s).All trademarks and registered trademarks arethe property of their respective owners

ContentsAbout . 1Chapter 1: Getting started with Java Language . 2Section 1.1: Creating Your First Java Program . 2Chapter 2: Type Conversion . 8Section 2.1: Numeric primitive casting . 8Section 2.2: Basic Numeric Promotion . 8Section 2.3: Non-numeric primitive casting . 8Section 2.4: Object casting . 9Section 2.5: Testing if an object can be cast using instanceof . 9Chapter 3: Getters and Setters . 10Section 3.1: Using a setter or getter to implement a constraint . 10Section 3.2: Why Use Getters and Setters? . 10Section 3.3: Adding Getters and Setters . 11Chapter 4: Reference Data Types . 13Section 4.1: Dereferencing . 13Section 4.2: Instantiating a reference type . 13Chapter 5: Java Compiler - 'javac' . 14Section 5.1: The 'javac' command - getting started . 14Section 5.2: Compiling for a di erent version of Java . 16Chapter 6: Documenting Java Code . 18Section 6.1: Building Javadocs From the Command Line . 18Section 6.2: Class Documentation . 18Section 6.3: Method Documentation . 19Section 6.4: Package Documentation . 20Section 6.5: Links . 20Section 6.6: Code snippets inside documentation . 21Section 6.7: Field Documentation . 22Section 6.8: Inline Code Documentation . 22Chapter 7: Command line Argument Processing . 24Section 7.1: Argument processing using GWT ToolBase . 24Section 7.2: Processing arguments by hand . 24Chapter 8: The Java Command - 'java' and 'javaw' . 27Section 8.1: Entry point classes . 27Section 8.2: Troubleshooting the 'java' command . 27Section 8.3: Running a Java application with library dependencies . 29Section 8.4: Java Options . 30Section 8.5: Spaces and other special characters in arguments . 31Section 8.6: Running an executable JAR file . 33Section 8.7: Running a Java applications via a "main" class . 33Chapter 9: Literals . 35Section 9.1: Using underscore to improve readability . 35Section 9.2: Hexadecimal, Octal and Binary literals . 35Section 9.3: Boolean literals . 36Section 9.4: String literals . 36Section 9.5: The Null literal . 37Section 9.6: Escape sequences in literals . 37

Section 9.7: Character literals . 38Section 9.8: Decimal Integer literals . 38Section 9.9: Floating-point literals . 39Chapter 10: Primitive Data Types . 42Section 10.1: The char primitive . 42Section 10.2: Primitive Types Cheatsheet . 42Section 10.3: The float primitive . 43Section 10.4: The int primitive . 44Section 10.5: Converting Primitives . 45Section 10.6: Memory consumption of primitives vs. boxed primitives . 45Section 10.7: The double primitive . 46Section 10.8: The long primitive . 47Section 10.9: The boolean primitive . 48Section 10.10: The byte primitive . 48Section 10.11: Negative value representation . 49Section 10.12: The short primitive . 50Chapter 11: Strings . 51Section 11.1: Comparing Strings . 51Section 11.2: Changing the case of characters within a String . 53Section 11.3: Finding a String Within Another String . 55Section 11.4: String pool and heap storage . 56Section 11.5: Splitting Strings . 57Section 11.6: Joining Strings with a delimiter . 59Section 11.7: String concatenation and StringBuilders . 60Section 11.8: Substrings . 61Section 11.9: Platform independent new line separator . 62Section 11.10: Reversing Strings . 62Section 11.11: Adding toString() method for custom objects . 63Section 11.12: Remove Whitespace from the Beginning and End of a String . 64Section 11.13: Case insensitive switch . 64Section 11.14: Replacing parts of Strings . 65Section 11.15: Getting the length of a String . 66Section 11.16: Getting the nth character in a String . 66Section 11.17: Counting occurrences of a substring or character in a string . 66Chapter 12: StringBu er . 68Section 12.1: String Bu er class . 68Chapter 13: StringBuilder . 69Section 13.1: Comparing StringBu er, StringBuilder, Formatter and StringJoiner . 69Section 13.2: Repeat a String n times . 70Chapter 14: String Tokenizer . 71Section 14.1: StringTokenizer Split by space .

Java Java Notes for Professionals Notes for Professionals GoalKicker.com Free Programming Books Disclaimer This is an uno cial free book created for educational purposes and is not a liated with o cial Java group(s) or company(s). All trademarks and registered trademarks are the property of their respective owners 900 pages