Home> Java> javaTutorial> body text

Is there var to define variables in java?

下次还敢
Release: 2024-04-26 23:21:12
Original
1056 people have browsed it

There is no var keyword in Java to create a variable, you need to follow the following syntax: Specify the variable data type Specify the variable name Optional: Specify the variable initial value

Is there var to define variables in java?

There is novarkeyword to define variables in Java

The following syntax is used to define variables in Java:

<数据类型> <变量名> [= <初始值>];
Copy after login

whereSpecify the data type stored in the variable,is the name of the variable,(optional) is the initial value of the variable.

For example:

int age = 20; String name = "John Doe"; double pi = 3.14;
Copy after login

These codes define three variables:age(integer),name(string) andpi(double precision floating point number).

The above is the detailed content of Is there var to define variables in java?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!