---------------------------------------
Classification of data types in Java:
Basic Data type: 4 Class 8 kinds. BYTE, short, int (integer default), long, float, double (decimal default), Char, Boolean
Reference data types: classes, interfaces, arrays, strings, lambda, and so on.
Note: The two reference data types, string, lambda, are learned later.
---------------------------------------
How do you use classes in reference data types in Java?
In Java 9 or earlier, in addition to 8 basic data types, other data types belong to the reference data type.
If you want to use "classes" in reference types, the general steps for typical usage are:
For example, use a scanner class Scanner that is already written by the JDK in Java.
Step 1: Guide the package.
Specify where you want the target to be used. Write the code on a line before the public class:
Import xxx.yyy.zzz. class name;
For example:
Import Java.util.Scanner; //This method imports the level that is imported to the class.
Step 2: Create the object.
Want to use the function inside this class, need to create object Ah!
Reference data types generally require creation of objects to be used in the following format:
Data type variable name = new data type ();
For example:
Scanner sc = new Scanner (system.in);
Step 3: Call.
What features you need to use, just one feature name (method name), in the format:
The name of the variable. Method name ();
For example:
A: Gets the int number of the keyboard input
int num = Sc.nextint ();
B: Get the keyboard input string
String str = Sc.next ();
---------------------------------------
How do you use classes in reference data types in Java?