An article released exclusively on October 09, 2017. I referred to "** Introduction to Java that can be understood clearly **".
Java SE from Oracle, IntelliJ from JET BRAINS DL and install IDEA. The Atom editor is also useful.
Main.java
public class Main{
public static void main(String args[]){
int variable name=value;
final int constant name=value; //Constant name is uppercase
}
}
Classification | Model name | Stored data |
---|---|---|
integer | long | Big |
int | usually | |
byte | -128 ~ 127 | |
Decimal | double | usually |
float | ambiguous | |
Boolean value | boolean | true / false |
letter | String | String |
char | One character |
Main.java
int age = 15;
operator | function | Evaluation direction |
---|---|---|
++ | Left side=Left side+ 1 | -> |
-- | Left side=Left side- 1 | -> |
* | Multiply | -> |
/ | division | -> |
% | Surplus division | -> |
+ | Addition | -> |
String concatenation | -> | |
- | Subtraction | -> |
= | Substitution | <- |
+= | Left side=Left side+right side | <- |
"Left side" = "Left side" + "right side" | <- | |
-= | Left side=Left side-right side | <- |
*= | Left side=Left side*right side | <- |
/= | Left side=Left side/right side | <- |
%= | Left side=Left side%right side | <- |
Main.java
//Screen output(With line breaks)
System.out.println("String");
//Screen output(No line breaks)
System.out.print("String");
//Convert strings to numbers
int n = Integer.parseInt(String);
//Random number generation
int r = new java.util.Random().nextInt(upper limit);
//Input reception from keyboard
String m = new java.util.Scanner(System.in).nextLine();
int n = new java.util.scanner(System.in).nextInt();
operator | meaning |
---|---|
== | Left side=right side |
!= | Left side ≠ right side |
> | Left side>right side |
< | Left side>right side |
>= | Left side ≧ right side |
<= | Left side ≤ right side |
&& | Conditional expression 1 ∨ Conditional expression 2 |
|| | Conditional expression 1 ∧ Conditional expression 2 |
Main.java
if (Conditional expression 1) {
Block 1
} else if(Conditional expression 2) {
Block 2
} else {
Block 3
}
When evaluating ** a match between the left and right sides of ** integers, strings, and characters **, the If-ElseIf-Else statement can be rewritten as a Switch statement.
Main.java
switch(Condition value) {
case value 1:
Process 1
case value 2:
Process 2
break; //Suspend the process itself
default:
Default processing
}
Main.java
do{
block
}while (Conditional expression) {
block
}
You should use a For statement when you know the number of iterations.
Main.java
for (int i = 0; i < 10; i++) {
block
if (i == 7) {
continue; //Cancel the current lap
}
}
while (true) {
block//infinite loop
for (;;) {
block//infinite loop
}
}
Main.java
int[]Array name= {Value 0,Value 1...Value n}
Array name= null; //Cut the array
Number of elements in int array=Array name.length;
//Extended For statement
for(int arbitrary variable name:Array name) {
block
}
Recommended Posts