Variables and data types

Original link: https://www.lifengdi.com/archives/course/java/3907

Variables What are variables? Variables are the algebraic concept of junior high school mathematics, such as a simple equation, x and y are variables: y=x^2+1 In Java, variables are divided into two types: basic type variables and reference type variables. Let’s start by discussing basic types of variables. In Java, variables must be defined before use. When defining a variable, you can give it an initial value. For example: int x = 1; The above statement defines a variable of type int, whose name is x, and whose initial value is 1. Not writing the initial value is equivalent to specifying a default value for it. The default value is always 0. Take a look at a complete example of defining a variable and then printing the value of the variable: // define and print the variable public class Main […]

This article is reproduced from: https://www.lifengdi.com/archives/course/java/3907
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment