I joined an SES company as a new graduate in April this year. Currently, he is resident at a major SIer and is participating in a project subsidized by the Ministry of Economy, Trade and Industry.
You cannot log in to your personal computer on your business PC. I can't see my memo, so I searched for Qiita and posted it.
This is a Java memo for new employee training.
The for statement is suitable for simple iterations. When the number of repetitions is fixed. It is suitable for while statements and iterative processing that requires complicated processing.
・ For sentence repeat ① Initialization process int i = 0; ② Repeat condition i <10; ③ Repeated processing i ++
・ While statement repeats (between) → Control syntax components [Conditional expression] An expression showing branching conditions and conditions for continuing repetition [Block] A collection of sentences to be executed by branching or repeating
-Switch statement Processing corresponding to each case case 1; (in the case of) case 2; (in the case of) case 3; (in the case of)
・ Break statement Used when interrupting repetition (required for switch statement)
-Continue statement: Unlike the break statement, the repetition is not interrupted. (Skip to the next process)
"Array" is a typical example. A data structure that stores the same type of data side by side. It is called a "reference type" because it refers to an address in memory.
The reference type has no specific value, new, and assigns a pointer (address in memory) to the instance as a reference value.
(Primitive types start with all lowercase letters. Unlike reference types, they have no methods. Specific data values (numerical values and characters) written directly to the memory can be assigned. )
-Creation (declaration) of array variables
//Element type[ ]Array variable name= new Element type[ ];
int[] score = new int[5];
-Array for loop (used when executing iterative processing under specified conditions)
public class Main {
public static void main(String[] args) {
int[] score = {1,2,3,4,5};
for (int i = 0; i < score.length; i++){ //Array name.Get the number of elements by length.
System.out.println(score);
}
}
}
-Extended for statement (Unlike a normal for statement, it is not possible to extract some elements)
public class Main {
public static void main(String[] args) {
int[] score = {1,2,3,4,5};
for (int value : score){ //When the loop goes around once, the next element enters value.
System.out.println(value);
}
}
}
→ Divide the process in the main method into multiple methods and take charge of each process. Example) The boss (main method) assigns work to his subordinates (other methods).
Java programs start from main.
・ Advantages of the method (1) The outlook of the program is improved and it is easier to grasp the whole. (2) Since it is described in functional units, the correction range can be limited. (3) Work efficiency is improved by combining the same processing into one method.
-Method call Method name (argument list)
//Example) hello();Call the hello method
public class Main {
public static void main(String[] args) {
System.out.println("Call the method.");
hello();
System.out.println("The method has finished calling.");
}
public static void hello() {
System.out.println("Hello");
}
}
/*Execution result
Call the method.
Hello
The method has finished calling.
*/
-Overloading (overloading) means defining a method with the same name. → Valid if the number or type of formal arguments is different Invalid if the arguments are the same but only the return type is different
-Both the sender and the receiver are called arguments, but they can be subdivided. Argument on the sending side → actual argument (argument) Recipient argument → Formal argument (parameter)
SES resident at the customer's site may have a narrow shoulder. I will do my best to learn Java while doing my best!
[Introduction to Java that is refreshingly understood 3rd edition (refreshing series)] (https://www.amazon.co.jp/%E3%82%B9%E3%83%83%E3%82%AD%E3%83%AA%E3%82%8F%E3%81%8B%E3%82%8BJava%E5%85%A5%E9%96%80-%E7%AC%AC3%E7%89%88-%E3%82%B9%E3%83%83%E3%82%AD%E3%83%AA%E3%82%B7%E3%83%AA%E3%83%BC%E3%82%BA-%E4%B8%AD%E5%B1%B1%E6%B8%85%E5%96%AC/dp/4295007803/ref=zg_bs_515820_1?_encoding=UTF8&psc=1&refRID=VVG291GHWRA9V6TW57NE/)
Thank you very much for your help. Great for getting started with Java basics and object orientation.
Recommended Posts