我有一个.swift文件,其中包含项目内容:
/*
v1.1: do this
v1.1.1: update this
v1.3: optimize this
*/
它超过100行,我认为可能有更好的方法来保存这些类型的音符。这是否会减少我的编译时间或影响我的项目?
答案 0 :(得分:1)
为这些笔记创建// Java Code Conventions: http://www.oracle.com/technetwork/java/codeconvtoc-136057.html
// Removed import java.io.* because it wasn't used
import java.util.Scanner; // I prefer explicit imports, not *
class Detail { // Class names are typically uppercase
// You don't have any visibility modifiers
// https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
private String name;
private int age;
private float salary;
// I would recommend a different name. Methods of the format
// getX() usually indicate that they return a value. These are
// called accessor methods
public void getData() { // Method names are usually camel case
Scanner sc = new Scanner(System.in);
System.out.println("enter name: ");
name = sc.next();
System.out.println("enter age: ");
age = sc.nextInt();
System.out.println("enter salary: ");
salary = sc.nextFloat();
// You should close input methods
sc.close();
}
public void display() {
System.out.println("name: " + name);
System.out.println("age: " + age);
System.out.println("salary: " + salary);
}
}
class Person { // Classes are usually uppercase names
public static void main(String arr[]) {
Detail p = new Detail();
p.getData();
p.display();
}
}
文件。 todo.swift
文件允许链接可点击,也可以启用着色。其他格式如.swift
不允许这些格式。