Links & memos for getting started with Java (for myself)

The site I referred to when learning Java (a super personal memorandum ...)

Samurai Blog

-[Let's understand] Explain how to draw a UML class diagram -[Introduction to Java] Summary of how to use the constructor (class / instance) -[Introduction to Java] What is this? I will explain the meaning and usage of Kihon! -[Java] What is super? Detailed explanation of meaning and usage -[Introduction to Java] Inheritance and call to constructor (super / this)

Design pattern (TECH SCORE)

-Design Pattern INDEX

Tips

Increment / decrement on return

at a time like this

Main.java


class SampleClass {
    private int member1=0;

    public int incrementLocal1(int local){
        return local++;
    }
}
public class Main {
  public static void main(String[] args){
    SampleClass sc = new SampleClass();
     System.out.println("Local variables: " + sc.incrementLocal1(0));
  }
}

Execution result → I expected a local variable: 1, but ...

Local variables: 0

The incremented value is not returned, so review it.

Main.java


class SampleClass {
    private int member1=0;

    public int incrementLocal1(int local){
        //return local++;
        return ++local;  //Write the increment operator before the variable.
    }
}
public class Main {
  public static void main(String[] args){
    SampleClass sc = new SampleClass();
     System.out.println("Local variables: " + sc.incrementLocal1(0));
  }
}

Execution result

Local variables: 1

So, about the increment operator / decrement operator

If you write before the variable, "increment / decrement at the start of processing"

image


i=i+1;
return i;

If you write after the variable, "increment / decrement after the end of processing"

image


return i;  //The value before being incremented is returned
i=i+1;

Recommended Posts

Links & memos for getting started with Java (for myself)
Getting Started with Ruby for Java Engineers
Getting Started with Java Collection
Getting Started with Java Basics
Enable OpenCV with java8. (For myself)
Getting started with Java lambda expressions
Getting Started with Docker for Mac (Installation)
Getting Started with Java Starting from 0 Part 1
Getting Started with DBUnit
Getting Started with Ruby
Getting Started with Java 1 Putting together similar things
Getting started with Kotlin to send to Java developers
Getting Started with Swift
Getting Started with Docker
Getting Started with Doma-Transactions
Getting started with Java programs using Visual Studio Code
Getting Started with Legacy Java Engineers (Stream + Lambda Expression)
Getting Started with Doma-Annotation Processing
Getting Started with JSP & Servlet
Getting Started with Spring Boot
Getting Started with Ruby Modules
Getting Started with Java_Chapter 5_Practice Exercises 5_4
[Google Cloud] Getting Started with Docker
[Android Studio] [Java] Learning memos & links
Getting Started with Docker with VS Code
Getting Started with Doma-Criteria API Cheat Sheet
Learn Java with "So What" [For beginners]
Getting Started with Parameterization Testing in JUnit
Getting Started with Ratpack (4)-Routing & Static Content
Getting started with the JVM's GC mechanism
Interoperability tips with Kotlin for Java developers
Getting Started with Language Server Protocol with LSP4J
Getting Started with Machine Learning with Spark "Price Estimate" # 1 Loading Datasets with Apache Spark (Java)
Getting Started with Creating Resource Bundles with ListResoueceBundle
For my son who started studying Java with "Introduction to Java" in one hand
Getting Started with Java_Chapter 8_About Instances and Classes
[Java] How to test for null with JUnit
Summary of Java environment settings for myself [mac]
Ask for n business days later with JAVA
Getting Started with Doma-Using Projection with the Criteira API
Simple obstacle racing made with processing for Java
Getting Started with Doma-Using Subqueries with the Criteria API
Getting Started with Doma-Using Joins with the Criteira API
Docker Container Operations with Docker-Client API for Java
Getting Started with Doma-Introduction to the Criteria API
I tried Getting Started with Gradle on Heroku
For JAVA learning (2018-03-16-01)
Going back to the beginning and getting started with Java ① Data types and access modifiers
2017 IDE for Java
Java for statement
Experienced Java users get started with Android application development
Java programming exercises for newcomers unpopular with active engineers
[Java basics] Let's make a triangle with a for statement
Get Azure App Service for Java Configuration with System.getEnv ()
Generate dummy data for various tests with Faker (java)
[Java] Environment construction procedure for developing struts 1.3 with Eclipse
(For myself) Build gitlab with ubuntu18.04 + docker for home (Note)
Try connecting to AzureCosmosDB Emulator for Docker with Java
Prepare the environment for java11 and javaFx with Ubuntu 18.4
Links for each version (Japanese version) of Java SE API
Get started with serverless Java with the lightweight framework Micronaut!