[Java] Classification memo of compilation error and run-time error

Classification of cases that cause compile errors and cases that cause run-time errors.

Case of compilation error

Lambda type mismatch

BiFunction<Integer, Double, Integer> function = (x, y) -> x + y;
function.apply(1, 2.5);

(int)(x + y)Orbifunction<integer, double, double>Needs to be fixed.

Execution case

Call reset () on FileInputStream

FileInputStream can call reset () but does not support it. Supported by the child class BufferedInputStream.


new FileInputStream("src/a/a.txt").reset();
//=> java.io.IOException: mark/reset not supported

Reset () of InputStream of parent class

public synchronized void reset() throws IOException {
        throw new IOException("mark/reset not supported");
    }

Reset () of BufferedInputStream of child class

public synchronized void reset() throws IOException {
        getBufIfOpen(); // Cause exception if closed
        if (markpos < 0)
            throw new IOException("Resetting to invalid mark");
        pos = markpos;
    }

Recommended Posts

[Java] Classification memo of compilation error and run-time error
Advantages and disadvantages of Java
Summary of java error processing
[Java] Difference between Stack Overflow Error and Out Of Memory Error
About fastqc of Biocontainers and Java
Flowing interface trial and error memo
[Java] Judgment of identity and equivalence
After 3 months of Java and Spring training
Memo: [Java] Check the contents of the directory
About the classification and concept of Immutable / Mutable / Const / Variable of Java and Kotlin.
Java memo
[Java] Inheritance and structure of HttpServlet class
[Ruby] Classification and usage of loops in Ruby
Summary of Java Math.random and import (Calendar)
[Java ~ Classes and External Libraries ~] Study Memo (6)
[Java] Contents of Collection interface and List interface
Basics of java basics ② ~ if statement and switch statement ~
Discrimination of Enums in Java 7 and above
Install Docker and create Java runtime environment
Java compilation error Unable to map to encoding windows-31j
[Java] Personal summary of classes and methods (basic)
I compared the characteristics of Java and .NET
JAVA: Realizes generation and scanning of various barcodes
Basics of threads and Callable in Java [Beginner]
Introduction of Rspec and Japanese localization of error messages
Java enables extraction of PDF text and images
java anything memo
Java Silver memo
java, maven memo
A memo about the types of Java O/R mappers and how to select them
Today's java error
Java SE 7 memo
Java and JavaScript
java error countermeasures
XXE and Java
Maven3 error memo
[Java] Overview of Java
Java specification memo
Java pattern memo
[Java] Types of comments and how to write them
Summary of ToString behavior with Java and Groovy annotations
Please note the division (division) of java kotlin Int and Int
The comparison of enums is ==, and equals is good [Java]
Organizing the current state of Java and considering the future
Java language from the perspective of Kotlin and C #
[Java] About Objects.equals () and Review of String comparisons (== and equals)
I summarized the types and basics of Java exceptions
List of frequently used Java instructions (for beginners and beginners)
[Technical memo] About the advantages and disadvantages of Ruby
Use of Abstract Class and Interface properly in Java
Equivalence comparison of Java wrapper classes and primitive types
[Java] [Kotlin] Generically call valueOf and values of Enum
[Java10] Be careful of using var and generics together
[Null safety] Kotlin Java comparison memo Correct use of Null safety
[Java] Handling of character strings (String class and StringBuilder class)
Memo to silently write the source that seems to be usable and the result of compilation execution-java