[Java] Basic summary of Java not covered by Progate ~ Part 1 ~

  1. package

For class, we will proceed on the assumption that we have some image. It is often explained that the class is a blueprint and the instance is actually generated based on the blueprint, but if you do not know the class, please google. I think it's common to other object-oriented programming languages.

What is a package

The basics of a java program start with creating a class. If you want to create a simple program, you only need to use a few classes, If you want to create a big program, you will use many classes. A package is a collection of classes and interfaces, and is classified according to usage. In java, various classes are prepared, including the object class, but these are all managed by the package. Different packages will be treated as different classes even if they have the same name.

Source: http://www1.bbiq.jp/takeharu/java51.html

Each Java ™ class belongs to a package. Which class is included in which package is stated in the first statement in the Java source file. If the source file does not have a package statement, the class is considered to be included in the unnamed default package.

Source: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_71/rzaha/clpckdir.htm

Package features

・ All classes belong to package -If package is not specified, it belongs to the default package -Collecting related classes into a package has the advantages of clarifying the development unit and making it easier to manage, and restricting access only from the same package. -The package name hierarchy corresponds to the directory hierarchy. (java.util.ArrayList corresponds to java / util / ArrayList.class)

How to specify the package to which the class belongs

python


package java.lang;

Declares to belong to java.lang.

What is import

-In order to uniquely identify a class, it must be described with a fully qualified name.

import and *

python


import java.util.*;

With this specification, all directory hierarchies directly under java.util can be specified.

2. Member variables

= Same for instance fields and instance variables.

3. Basic data type and reference type

If you think about it roughly, you can classify the types of variables into two types: basic data type (= primitive type, value type) and reference type (= class type).

What is a basic data type?

The following 8 types.

Mold Memory area Overview
boolean 1bit true or false
char 16bit Unicode single character
byte 8bit Signed integer-128~127
short 16bit Signed integer-32768~32767
int 32bit Signed integer-2147483648~2147483647
long 64bit Signed integer about-922 Kyo-about 922 Kyo
float 32bit Floating point number
double 64bit Floating point number

A variable of the basic data type means that its size (number of bits) is exactly determined by the type. This means that when a variable is declared, the used area of the variable in memory can be secured in just proportion. Any value can be kept within that fixed area (as long as it is within the range of that type).

Reference source: https://nobuo-create.net/sanshougata/

-Specific data values (numerical values and characters) written directly to the memory can be assigned, and the variables themselves have values. -Unlike the reference type, it does not have a method. ・ Starts with all lowercase letters.

What is a reference type?

-All are reference types except the basic data type. -Arrays and Strings are also reference types. -The reference type creates an object and stores the value (= reference value) for referencing the object in a variable.

Reference URL: https://www.mlab.im.dendai.ac.jp/~yamada/java/reference/

4. Constant

A variable whose value cannot be changed.

python


final int COUNT = 4;

Add final at the beginning and write in capital letters.

Recommended Posts

[Java] Basic summary of Java not covered by Progate ~ Part 1 ~
[Java] Basic summary of Java not covered by Progate ~ Part 2 · List ~
Summary of basic knowledge of Rails acquired by progate
Basic usage of java Optional Part 1
[Java] Personal summary of conditional statements (basic)
[Java] Personal summary of classes and methods (basic)
Summary of Java support 2018
Summary of revisions (new era) support by Java version
[Java11] Stream Summary -Advantages of Stream-
Progate Java (Beginner) Review & Summary
[Java] Summary of regular expressions
[Java] Summary of operators (operator)
Object-oriented summary by beginners (Java)
Summary of Java language basics
[Java] Summary of for statements
Summary of Java Math class
Summary of basic functions of ImageJ
[Java] Summary of control syntax
Summary of java error processing
[Java] Summary of design patterns
[Java] Summary of mathematical operations
Summary of values returned by the Spliterator characteristics method #java
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 10)
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 7)
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 3)
[For beginners] Summary of java constructor
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 9)
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 6)
Summary of [Java silver study] package
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 4)
The story of not knowing the behavior of String by passing Java by reference
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 5)
[Java] Output by FormatStyle of DateTimeFormatter
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 2)
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 1)
[Java] Appropriate introduction by the people of Tempa Java Part 0 (Code rules)
Basic processing flow of java Stream
Java "pass by reference" problem summary
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 11)
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 12)
Summary of object-oriented programming using Java
[Basic knowledge of Java] Scope of variables
Summary of "Design Patterns Learned in Java Language (Multithread Edition)" (Part 8)
Basic structure of Java source code
[Java Silver] Summary of access modifier points
Summary of in-house newcomer study session [Java]
[java] Summary of how to handle char
Summary of changes other than JEP of Java10
Summary of Docker understanding by beginners ② ~ docker-compose ~
Basic knowledge of Java development Note writing
[Java] [Maven3] Summary of how to use Maven3
[Basic knowledge of Java] About type conversion
Java Summary of frequently searched type conversions
Summary of Java Math.random and import (Calendar)
Java engineers now compare to learn the basic grammar of Ruby Part 1 (Basic, Variables)
progate java L1 basic summary console.log, difference between variables and constants, if statement
[java] Summary of how to handle character strings
Summary of Java environment settings for myself [mac]
[Docker] Introduction to docker compose Basic summary of docker-compose.yml
[Java] Dynamic method call by reflection of enum (enum)
[Java] Summary of how to abbreviate lambda expressions