Hoshiumi
星海日和
= 代码落在地上,故事落在星海 =
跨越星轨的客
技术 · 生活 · 番剧 · 音乐
Posts
The article systematically introduces the content related to file operations and IO streams in Java, covering the path processing of File classes, file and directory creation, recursive operations, and the use of byte streams and character streams. It focuses on the classification of IO streams, the combined use of node streams and processing streams, the functions and considerations of common stream classes (such as FileInputStream, BufferedInputStream, FileWriter, BufferedWriter, DataInputStream, ObjectOutputStream), and introduces the configuration file format (Properties, XML, YAML) and the core points of Apache POI to realize reading and writing Excel files.
This article systematically introduces the core concepts and common implementations of the Java Collection Framework. Collections encapsulate data structures such as arrays, linked lists, and hash tables through a unified interface. They have advantages such as dynamic length, type safety, and operation efficiency. Different collections have their own characteristics in terms of index, repetition, order, and thread safety. It focuses on explaining core interfaces such as List (ArrayList and LinkedList), Map (HashMap, TreeMap, LinkedHashMap), Set (HashSet, LinkedHashSet, TreeSet) and their implementation principles, emphasizing the usage specifications of generics, hash mechanisms, node structures and iterators. At the same time, it is pointed out that collection operations need to be combined with business scenario selection to avoid misuse or ignore thread safety and structural modification issues.
This article introduces the core classes commonly used in the Java.lang package, focusing on the toString(), equals(), hashCode(), and clone() methods of the Object class, emphasizes that hashCode() needs to be rewritten simultaneously when overriding equals(), and points out that finalize() should not be used for resource release. At the same time, it details the use methods, caching mechanisms and comparison specifications of eight basic types of wrapper classes (such as Integer), reminding them to avoid using == to compare the content of wrapper classes. It also introduces the immutability of String, constant pools, common methods and encoding and decoding issues with byte arrays, and compares the differences between StringBuffer and StringBuilder. It recommends using StringBuilder in single-threaded scenarios to improve performance.
This paper introduces the concept, function and application of interfaces in object-oriented design. Interfaces are used to establish behavioral specifications, reduce coupling between classes, support multiple implementations and unified calls, and function extensions can be achieved through inheritance and implementation. Combined with the UML class diagram, it shows the generalization, implementation, dependence, and association relationship between interfaces and classes, embodying the idea of "interface-oriented programming" in object-oriented design, as well as the practical application of factory patterns and aggregation design.
The article systematically introduces the usage scenarios and principles of several core keywords in Java: static members decorated with static belong to the class itself and are shared among all objects, and the initialization order strictly follows the code order;abstract is used to define abstract classes and abstract methods, abstract classes cannot be instantiated, and subclasses need to implement abstract methods;final is used to prohibit inheritance, rewriting, or multiple assignments, and is often used for constants and immutable designs; Inner classes include member inner classes, local inner classes, statically nested classes, and anonymous inner classes, each with different scopes and usage restrictions. Together, these features support the implementation of encapsulation, inheritance, polymorphism, and design patterns (such as singleton patterns) in Java object-oriented programming.
This article systematically introduces the core concepts and implementation details of object-oriented programming, including the definition of classes and objects, the use of member variables and methods, constructors, encapsulation, inheritance, polymorphism, access control, JAR package management, and JVM runtime data area and parameter passing mechanism. It focuses on the three major object-oriented features-encapsulation, inheritance and polymorphism, and illustrates key knowledge points such as member variable default values, method rewriting, dynamic binding, and upward/downward transformation with actual code examples. Programming specifications and best practices, such as string comparisons should be used to ensure consistency when rewriting equals(), parameter passing to value passing, etc.
This article systematically introduces the basic concepts and operations of Java arrays, including the definition, creation, access, traversal, sorting, search and copying operations of one-dimensional and two-dimensional arrays. It focuses on the memory model of the array, index rules, default values, out-of-bounds exceptions, and the use of common tool classes (such as Arrays). It also compares different initialization methods and traversal strategies, and emphasizes irregular two-dimensional arrays and deep copies. Implementation points.
The article introduces the use of Scanner utility classes in Java, including how to read user input, common problems when processing input (such as residual line terminators), and the syntax and application scenarios of basic conditional expressions, if-else, and switch statements. At the same time, it explains in detail the use scenarios, execution processes and control keywords (break, continue) of for, while and do-while loops, and provides analytical ideas for loop problems, such as exhaustive method and recurrence method, as well as nested loop application examples in graphic questions. Finally, the optimization method of prime number judgment and the implementation skills of integer digit extraction are mentioned.
This article systematically introduces the rules and considerations for the use of data types, variable definitions and scopes, constants, literals, and various operators (arithmetic, comparison, logic, bit operations) in Java. It focuses on explaining the characteristics of basic data types, precision issues and the principles of type conversion, emphasizing that precision loss, overflow and low-readability code should be avoided in actual development, and advocating the use of clear and safe expression methods.
This article introduces the basic configuration and development environment of Java, including how to set environment variables so that the command line can access Java commands, and the complete process of writing the first Java program. It explains in detail the Java code structure, naming convention, main method, output statements, binary representation, data storage method, character encoding and annotations, etc., and introduces the project creation, directory structure and common shortcut keys in IntelliJ IDEA, providing beginners with systematic guidance from environment configuration to basic programming.