j1-1_strings
This is an old revision of the document!
Table of Contents
J1-1 Strings
Welcome to the first course in Java!
Requirements:
- IntelliJ IDEA CE
You can download IntelliJ IDEA CE from the JetBrains webpage: https://www.jetbrains.com.cn/en-us/idea/download
Scroll down to the second option, the “Community Edition”, which is free.
The Code
Start a new project called “J1-1 Strings”. Then type the following code into the Main.java file:
Main.java
Main.java
public class Main {
public static void main(String[] args) {
// Code starts here:
// Print a message.
System.out.println("Hello, my name is Appledog!");
// Create a Scanner object to read input
Scanner scanner = new Scanner(System.in);
// Prompt the user for their name
System.out.print("What is your name? ");
// Read the input from the user
String name = scanner.nextLine();
// Output a response
System.out.println("Hello, " + name + "!");
// Close the scanner
scanner.close();
}
}
j1-1_strings.1732752353.txt.gz · Last modified: 2024/11/28 00:05 by appledog
