1.introduce java variable and hello wolrd
Let’s talk about “hello world!” Around the world,every person learning programming starts with “Hello world!”
So how to say hello world in program? This is simply code the following below:
public class HelloWorld { // This is the main function, serving as the entry point to the program. // In most programming languages, a program has only one main function, which serves as the entry point. public static void main(String[] args) { System.out.println("Hello World"); } }
package Test1.Test2;
public class TestVariable {
// This line defines a variable as an integer
int age; // only the definition, not yet assigned a value
// In Java, variables of the same type and with the same name cannot be defined more than once.
// You can define multiple variables at once on the same line.
int a, b;
// The definition and assignment of variables can be written on the same line.
int age1 = 19;
int c = 10, d = 20; // d was missing
int e, f = 30; // In this line, the variable e is not assigned a value, but f is assigned a value of 30.
// This is about using System.out.println function to output variable value
// How to use variable? See the following below:
public static void main(String[] args) {
TestVariable testVariable = new TestVariable();
testVariable.age = 25; // Assigning a value to age
System.out.println(testVariable.age); // Using the variable age
}
}
2. Data types
classification of data types mind map
- THE END -
非特殊说明,本博所有文章均为博主原创。
如若转载,请注明出处:https://www.asafe.top/programming/1.html