简介 | Introduction 意大利语: 本文提供意大利语和英语版本。向下滚动查看英语版本。 英语: 本文提供意大利语和英语版本。向下滚动查看英语版本。
Java 是全球最流行、应用最广泛的编程语言之一。凭借其跨平台特性,它广泛应用于桌面、移动、Web 甚至物联网 (IoT) 应用开发。本指南将介绍 Java 基础知识、开发环境搭建以及编写第一个程序的方法。
Java 是一种面向对象且跨平台的编程语言,这意味着用 Java 编写的程序可在任何支持 Java 虚拟机 (JVM) 的操作系统上运行。其设计目标包括:
开始 Java 编程前,需先搭建环境。
Java 开发工具包 (JDK) 包含编写和运行 Java 程序所需的所有工具。您可从 Oracle 官网下载:
立即学习“Java免费学习笔记(深入)”;
https://www.php.cn/link/573c38be55d418774b5efc274bb36461
IDE(集成开发环境)能简化代码编写和调试过程。常用的 Java IDE 包括:
将 JDK 路径添加到 JAVA_HOME 环境变量,并更新 PATH 以便从终端运行 Java 命令。
这是一个简单的 Java 程序示例,它会在控制台打印“Hello, world!”:
public class HelloWorld { public static void main(String[] args) { System.out.println("Ciao, mondo!"); } }
public class HelloWorld:定义名为 HelloWorld 的公共类。
public static void main(String[] args):程序的入口点。
System.out.println:将引号内的文本打印到控制台。
运行程序:
javac HelloWorld.java
java HelloWorld
您将看到“Ciao, mondo!”打印在控制台上。
变量和数据类型
变量用于存储数据。例如:
int numero = 10; // 整数 double prezzo = 19.99; // 小数 String nome = "Roberto"; // 文本
条件语句
if-else 结构示例:
if (numero > 5) { System.out.println("Il numero è maggiore di 5"); } else { System.out.println("Il numero è minore o uguale a 5"); }
循环
for 循环示例:
for (int i = 0; i < 10; i++) { System.out.println(i); }
Java 是一种功能强大且用途广泛的语言,非常适合编程入门者。掌握基础知识后,您可以探索更高级的主题,例如面向对象编程、框架等等。
Java is one of the most popular and widely used programming languages in the world. Its cross-platform nature makes it applicable to desktop, mobile, web, and even Internet of Things (IoT) applications. This guide will explore the fundamentals of Java, how to set up your development environment, and how to write your first program.
Java is an **object-oriented** and **cross-platform programming language**, meaning programs written in Java can run on any operating system that supports the Java Virtual Machine (JVM). It was designed with the goals of:
The Java Development Kit (JDK) contains all the tools needed to write and run Java programs. You can download it from the Oracle website:
https://www.php.cn/link/573c38be55d418774b5efc274bb36461
An IDE (Integrated Development Environment) simplifies writing and debugging code. Popular Java IDEs include:
Add the JDK path to the JAVA_HOME environment variable and update the PATH to run Java commands from the terminal.
Here's a simple Java program example that prints "Hello, world!" to the console:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } }
public class HelloWorld: Defines a public class named HelloWorld.
public static void main(String[] args): The entry point of the program.
System.out.println: Prints the text between the quotes to the console.
To run the program:
javac HelloWorld.java
java HelloWorld
You will see the message "Hello, world!" printed on the console.
Variables and Data Types
Variables are used to store data. Examples:
int number = 10; // integer double price = 19.99; // decimal number String name = "Roberto"; // text
Conditionals
Example of an if-else statement:
if (number > 5) { System.out.println("The number is greater than 5"); } else { System.out.println("The number is 5 or less"); }
Loops
Example of a for loop:
for (int i = 0; i < 10; i++) { System.out.println(i); }
Java is a versatile and powerful language well-suited for those starting their programming journey. After understanding the basics, you can explore more advanced topics such as object-oriented programming, frameworks, and much more.
This document was translated using a professional translation tool.
Questo documento è stato tradotto utilizzando uno strumento di traduzione professionale.
以上就是Java 编程简介:初学者指南 | Java 编程简介:初学者指南的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号