简体   繁体   English

在Eclipse中创建自定义类代码

[英]Creating custom class code in eclipse

I code java in eclipse, and i am spending time every new problem i write the same starting code. 我在eclipse中编写Java代码,我在每个新问题上都花时间,我编写了相同的起始代码。 So i wanted to create this as my custom class code: 所以我想创建它作为我的自定义类代码:

import java.util.*;

public class CLASSNAME {

public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

}

}

So i set my Preferences-Code templets-class body to that, but when i create a class i get this: 所以我将我的Preferences-Code Templets类主体设置为该类,但是当我创建一个类时,我得到了这个:

public class CLASSNAME {
import java.util.*;

public class CLASSNAME {

public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

}

}}

How do i stop that from happening? 我如何阻止这种情况发生?

Have you tried putting import java.util.*; 您是否尝试过import java.util.*; in "New Java files" instead of "Class body"? 在“新Java文件”而不是“类主体”中?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM