[JAVA] How to handle an instance

This is my own memo for learning Java.

What is an instance?

・ A realization of the class (blueprint) -Saved in the heap area * 1 ・ Generate using the keyword new * 2

What is a reference type variable?

-Contains a reference (such as an address: link information) to the instance, not the instance itself -Also called an object type variable -There is null as a special value that indicates that there is no reference.

What is a primitive type variable?

・ The variable itself is data ・ Int type, double type, char type, etc. ・ Basic type provided as a specification

Constructor method

-Automatically executed at the same time as instantiation -The method name must be the same as the class name -Cannot describe return type -Can be called only when an instance is created -Automatically defined by the compiler without being defined by the programmer (default constructor) -When executing a program, other methods can be called after the constructor processing is completed.

Garbage collection

-There is an automatic memory management function that automatically discards instances that are no longer needed from memory, and this is called a "garbage collector". -The garbage collector automatically determines when garbage collection is executed. -The act of the garbage collector destroying an instance in memory

Overload

-Method names and arguments are collectively called signatures. -Different signatures are identified by the compiler and JVM as different methods ・ Constructor can also be overloaded

Class variables and class methods

-There is a mechanism to store a class file in a part of the heap area and create an instance from it. -The area where this class file is stored is called the "permanent area". -Methods and fields with static modifiers are created in the static area. -Static methods and fields can be used even if no instance has been created. -A compile error occurs when trying to access an instance member from a static member

Recommended Posts

How to handle an instance
How to create an application
How to handle uploaded images
How to install Ruby on an EC2 instance on AWS
How to insert an external library
How to create an application server on an EC2 instance on AWS
How to crop an image with libGDX
How to blur an image (super easy)
How to publish an application on Heroku
[Easy-to-understand explanation! ] How to use Java instance
How to deploy
How to publish an application using AWS (3) EC2 instance environment construction
How to define an inner class bean
How to handle sign-in errors with devise
How to create a web server on an EC2 instance on AWS
How to write an RSpec controller test
[Rails] How to handle data using enum
[java] Summary of how to handle character strings
How to write an if statement to improve readability-java
How to use an array for HashMap keys
Rails6.0 ~ How to create an eco-friendly development environment
How to handle optional in Protocol Buffers (proto3)
How to solve an Expression Problem in Java
[Rails] How to build an environment with Docker
How to build an executable jar in Maven
How to make an crazy Android music player
How to create an oleore certificate (SSL certificate, self-signed certificate)
How to develop OpenSPIFe
How to call AmazonSQSAsync
How to use Map
How to write Rails
How to use rbenv
How to use letter_opener_web
How to use fields_for
How to use java.util.logging
How to check if an instance variable is defined in a Ruby class
How to use map
How to use collection_select
How to adapt Bootstrap
How to use Twitter4J
How to use active_hash! !!
How to install Docker
How to use MapStruct
How to use hidden_field_tag
How to use TreeSet
How to uninstall Rails
How to install docker-machine
[How to use label]
How to make shaded-jar
How to use identity
How to use hashes
How to write Mockito
How to create docker-compose
How to use JUnit 5
How to install MySQL
How to write migrationfile
How to build android-midi-lib
How to use Dozer.mapper
How to use Gradle
How to use org.immutables
How to use java.util.stream.Collector