[Beginner] Java basic "array" description

How to write an array of java

I'm new to Java. I will describe what I have learned.

1. Array

When carefully arranging one by one


 String[] memo = new String[5];    //Assign 5 arrays to memo variables

 memo[0] = "Daikon radish" ;
 memo[1] = "Carrot" ;
 memo[2] = "Mackerel" ;
 memo[3] = "Lemon" ;
 memo[4] = "Mustard" ;


 String fruits = memo[3] ;     //memo[3]Substitute an array of
 System.out.println( fruits );


(Console execution result)

Lemon

The above abbreviation
 String[] memo = {"Daikon radish","Carrot","Mackerel","Lemon","Mustard"};

 String fruits = memo[0] ;     
 System.out.println( fruits )

2. Description of two-dimensional array

 String[][] animal = {

      {"Eagle","Taka"},
      {"Chinchilla","hamster"},
      {"Parakeet","Pigeon"},
      {"Dachshund","Chihuahua"}

 };


 System.out.println(animal[0][0]);   //Eagle

 System.out.println(animal[0][1]);   //Taka

 System.out.println(animal[1][0]);   //Chinchilla

 System.out.println(animal[1][1]);   //hamster

 System.out.println(animal[2][0]);   //Parakeet

 System.out.println(animal[2][1]);   //Pigeon

 System.out.println(animal[3][0]);   //Dachshund

 System.out.println(animal[3][1]);   //Chihuahua

Instructions for using command line arguments in Eclipse

From the target file, "Execution" → "Execution configuration" 2.png

Search for the target file → select 3.png 4.png

Select "Arguments" and enter the array information in "args" (if there are multiple, put a space) 5.png

int variable= Integer.parseInt(args[0])

 class args {
      public static void main (String[] args) {
	
		String input1 = args[0] ;  //iOS is included
		String input2 = args[1] ;  //Android is included
		String input3 = args[2] ;  //windows are included
		String input4 = args[3] ;  //Mac is in

		System.out.println( input1 );
		
		System.out.println( input2 );
		
		System.out.println( input3 );
		
		System.out.println( input4 );
		
      }
 }

Recommended Posts

[Beginner] Java basic "array" description
[Java] array
Java array
Java array
java (array)
[Java] Array
java beginner 3
java beginner
java array
[Java] Array
Java basic learning content 2 (array / ArrayList)
Java basic grammar
[Java] Array notes
Java basic knowledge 1
Java Beginner Exercises
[Java] Basic structure
[Java] [Basic] Glossary
Java basic grammar
[Java beginner] About initialization of multidimensional array
Java basic grammar
Java exercises [Basic]
Java Exercise "Beginner"
java basic knowledge memo
[Java] Data type ①-Basic type
Java basic date manipulation
About Java Array List
Java basic naming conventions
[Java ~ Array ~] Study memo 4
Java learning memo (basic)
[Java] Basic method notes
Java basic data types
Basic Java OOps concepts
[Beginner] Create a competitive game with basic Java knowledge
Java basic learning content 7 (exception)
[Java] List type / Array type conversion
Basic Authentication with Java 11 HttpClient
Java basic syntax + α trap
[Java] Basic statement for beginners
Java starting from beginner, override
Java basic learning content 5 (modifier)
[Java] Thymeleaf Basic (Spring Boot)
Implement Basic authentication in Java
Java, instance starting from beginner
Java starting from beginner, inheritance
Java Development Basics ~ Exercise (Array) ~
[Java] Convert ArrayList to array
[Java Silver] Array generation method
How to initialize Java array
Java basic learning content 4 (repetition)
[Java] Basic terms in programming
Solve AtCoder Beginner Contest 151 in java
Differences between "beginner" Java and Kotlin
Solve AtCoder Beginner Contest 150 in java
Java learning memo (creating an array)
Solve AtCoder Beginner Contest 153 in java
[Java beginner] About abstraction and interface
Java basic learning content 3 (operator / ternary operator)
Basic data types and reference types (Java)
Java basic learning content 9 (lambda expression)
Basic usage of java Optional Part 1
[Java] Output multidimensional array / spreadsheet (AOJ⑥ spreadsheet)