Java review ③ (Basic usage of arrays / reference type)

Part 1 "Data structure"

  1. What is a data structure? A format that stores data according to certain rules Part 2 "array"
  2. What is an array? A type of data structure A variable-like box called an element that is lined up continuously.
  3. Array rules (1) The types of elements in the array must be the same. ② index (subscript) starts from 0.
  4. How to write an array Introduction of characters: Array variables (containers of elements) and elements ① Declaration of array variables int[ ] nums; Element type + array variable name ② Create and assign elements nums = new int[7]; Array variable name = new operator + create 7 elements of int type
  1. How to check the length of the array nums.length;
  2. Assignment to element nums[index] = 30;
  3. Display the contents of the element. System.out.print( nums[indes] );
  4. Characteristics of array initialization Variables cannot be compiled without initialization. But the array does not need to be initialized. The contents of all elements are 0 (To be exact, it is automatically initialized)
  1. Easy way to write an array. int [ ] nums = new int[3] {10, 20 ,30}; To write it more simply int [ ] nums = {10, 20, 30}; Part 3 "Combination of array and for statement"
  2. Turn the array using the for statement. for ( int i = 0; i < nums.length; I++ ) { System.out.println( nums[ i ] ) }
  1. Application of array turning for ( int i = 0; i < nums.length; i++ ) { sum += nums[ i ] }; for ( int i = 0; I < nums.length; i++ ) { if ( nums[ i ] > 1 ) { count++; } }
  2. Extended for statement for ( int num : nums ) { System.out.print( num ) }; Part 4 "Reference type" Array variables are called reference variables. The array variable remembers the start address of the element to be assigned, and when calling the array variable Using the start address of the element stored in the array variable, refer to the element and output the value of the element.

Recommended Posts

Java review ③ (Basic usage of arrays / reference type)
Basic usage of java Optional Part 1
[Java] Difference between assignment of basic type variable and assignment of reference type variable
Review of java Shilber
[Java] Data type ①-Basic type
NIO review of java
About Java basic data types and reference type memory
[Java] Mirage-Basic usage of SQL
Basic data type and reference type
Basic methods of Ruby arrays
Super basic usage of Eclipse
Review of Ruby basic grammar
Basic data types and reference types (Java)
[Java] Reference / update of Active Directory
Basic processing flow of java Stream
[Java] Correct comparison of String type
Java basic data types and reference types
[Basic knowledge of Java] Scope of variables
Basic structure of Java source code
Profiling with Java Visual VM ~ Basic usage ~
[Java] Implicit type cast (AOJ10-sum of numbers)
[Easy-to-understand explanation! ] Reference type type conversion in Java
Examine the memory usage of Java elements
Java review
[Java] Personal summary of conditional statements (basic)
[Java] Comparison of String type character strings
Java Summary of frequently searched type conversions
Introduction and basic usage of Simple Calendar gem
A quick review of Java learned in class
Java Welcome to the Swamp of 2D Arrays
Java type conversion
[JAVA] Stream type
Java basic grammar
[Java] Enumeration type
Java basic grammar
Java Optional type
Java8 method reference
Java basic knowledge 1
[Java] Basic structure
Java double type
About Java arrays
Java basic grammar
java8 method reference
JAVA reference materials
My Java reference
Java IO review
[Java] Overview of Java
Java exercises [Basic]
[Java] Basic summary of Java not covered by Progate ~ Part 1 ~
Feel the basic type and reference type easily with ruby
A quick review of Java learned in class part4
Java review ① (development steps, basic grammar, variables, data types)
[Java] About Objects.equals () and Review of String comparisons (== and equals)
GetXxxx of ResultSet was addicted to primitive type (Java)
Introduction to Java for beginners Basic knowledge of Java language ①
Feel the basic type and reference type easily with ruby 2
A quick review of Java learned in class part3
A quick review of Java learned in class part2
List data structure [Java / Scala]
[Java] Basic structure
[Swift] Type type ~ Structure ~
[Java] One type of alphabet prohibited FizzBuzz with binding [Binding]