Java第二次学习笔记

java学习笔记(2)

目录

键盘录入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.Scanner;

public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int i=sc.nextInt();
System.out.print("Enter another number: ");
int j=sc.nextInt();
System.out.println("i:"+i+" j:"+j+"\nThe sum is: "+(i+j));
}
}
/*
1.导包:import java.util.Scanner;
2.创建Scanner对象:Scanner sc = new Scanner(System.in);
3.提示用户输入:System.out.print("Enter a number: ");
4.读取用户输入的整数:int i=sc.nextInt();
5.提示用户输入:System.out.print("Enter another number: ");
6.读取用户输入的整数:int j=sc.nextInt();
7.输出结果:System.out.println("i:"+i+" j:"+j+"\nThe sum is: "+(i+j));
*/

java.util:包含集合框架,一些国际化支持类,服务加载器,属性,随机数生成,字符串解析和扫描类,base64编码和解码,位数组和几个其他实用程序类。 此包还包含旧版集合类和旧版日期和时间类。

IDEA

项目结构介绍

  1. 项目project
  2. 模块module
  3. 包(包就是文件夹)package
  4. 类class

常用设置

1.注释颜色:File->Setting->Editor->Colors&Fonts->JavaDoc Comments->Foreground Color可调成绿色
2.自动导包:File->Setting->General->Auto Import->Add unambiguous imports on the fly和Optimize imports on the fly勾选上
3.自动补全时忽略大小写:File->Setting->Editor->Code Completion->Match case取消勾选
4.将语言设置为中文:File->Setting->Plugins->Search for “Chinese Language Pack”安装中文语言包

快捷键

  1. 编译运行:Ctrl+Shift+F10
  2. 调试运行:Shift+F9
  3. 停止调试:Shift+F2
  4. 代码提示:Ctrl+Space
  5. 代码格式化:Ctrl+Alt+L

模块操作

  1. 创建模块:File->New->Module
  2. 导入模块:File->New->Import Module
  3. 打开模块:File->Open Module
  4. 关闭模块:File->Close Module
  5. 编译模块:Build->Compile Module ‘模块名’
  6. 运行模块:Run->Run Module ‘模块名’
  7. 调试模块:Debug->Debug Module ‘模块名’

__END__