Official site: Java SE Bronze
: cherry_blossom: ** Java Bronze SE passed **: cherry_blossom:
1, Java data type (primitive type, reference type) 2, Declaration and initialization of variables and constants, valid range of values 3, Declaration, creation and use of arrays (one-dimensional arrays) 4, Use command line arguments
** Primitive type **
byte short int long float double boolean char
** Reference type **
String
Variables
Variable.java
class Variable {
public static void main(String[] args) {
-- Primitive type --
byte a = 1;
short b = 5;
int c = 10;
long d = 100L;
float e = 1.0F;
double f = 2.00;
boolean x = true;
boolean y = false;
char z = 'A';
-- Reference type --
String name = "java";
}
}
Constant * It is customary to use uppercase letters
Constant.java
class Constant {
public static void main(String[] args) {
-- Primitive type --
final int VALUE = 10;
-- Reference type --
final String NAME = "java";
}
}
Array.java
class Array {
public static void main(String[] args) {
-- int type --
int[] numbers = {5, 10, 15, 20};
-- String type --
String[] subjects = {"Japanease", "Math", "Social", "Sience", "English"};
for (int i = 0; i < numbers.length; i++) {
System.out.println(numbers[i]);
}
for (int i = 0; i < subjects.length; i++) {
System.out.println(subjects[i]);
}
}
}
CommandLine
> java "Class file name" "Value 1" "Value 2" ...
The main method receives command line arguments as an array of String class
CommandLine.java
class CommandLine {
public static void main(String[] args) {
System.out.println(args[0]);
System.out.println(args[1]);
"Frequently used instruction execution statements"
"Receives one line of string input from the keyboard"
String s = new java.util.Scanner(System.in).nextLine();
"Receives one line of integer input from the keyboard"
int input = new java.util.Scanner(System.in).nextInt();
System.out.println(s);
System.out.println(input);
}
}
If you have any ** advice ** or ** comments **, please do: blush: Timely corrections ❗️ 1, Data Declaration and Use 2, Loop statement
Recommended Posts