IDEA 快捷键和字体设置

IDEA的使用

一、IDEA

设置字体

点击File->Settings

文本字体设置

窗口字体设置

二、IDEA建立项目

步骤1:

步骤2:

三、IDEA快捷键

1.删除当前行,默认:Ctrl+Y

  • 可以修改为:Ctrl+D

2.复制当前行:Ctrl+Alt+下

3.代码补全:alt+/

4.单行注释/取消注释:Ctrl+/

5.导入该行需要的类,先配置auto import,然后使用alt+enter即可

6.快速格式代码:ctrl+alt+l

7.快速运行程序:alt+r,自定义的

  1. 生成构造器:alt+insert,然后选择constructor,然后选择需要的进行初始化的成员变量

  2. 查看一个类的层级关系:ctrl+H

  3. 将光标放在一个方法上,输入 ctrl + B , 可以定位到方法

  4. 自动的分配变量名 , 通过 在后面加.var

import java.util.Scanner;

public class ArrTest {
    public static void main(String[] args) {
        Mytool mt = new Mytool();

        int arr[] = {-1, 10, 8, 9, 45, 99};
        System.out.println("原数组");

        //快捷键自动分配变量名 加.var
        Scanner scanner = new Scanner(System.in);
        Scanner scanner1 = new Scanner(System.in);
        Mytool mytool = new Mytool();
        
        //快速定位 Ctrl+B
        mt.printArr(arr);
        mt.bubbleSort(arr);
        System.out.println("\n排序后");
        mt.printArr(arr);
    }
}

class Person{
    String name;
    int age;

    //构造器-构造器
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
}

class Mytool {

    //进行冒泡排序
    public void bubbleSort(int arr[]) {
        for (int i = 0; i < arr.length; i++) {//外层循环,length-1
            int temp = 0;
            for (int j = 0; j < arr.length - i - 1; j++) {//内层循环,length-1-i次
                if (arr[j] > arr[j + 1]) {//要求从小到大
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }

    //打印数组
    public void printArr(int arr[]) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
posted @ 2022-01-24 12:41  DL50  阅读(214)  评论(0编辑  收藏  举报