Java Eclipse字符串错误 [英] Java eclipse String Error

查看:80
本文介绍了Java Eclipse字符串错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手,但是正在遵循一些说明,但是当我进入字符串部分时

I'm New to Java and I am following some instruction, However When I get to the Strings section

public class String {
    public static void main(String[] args) {
        java.lang.String name;
        name = "luke";
        System.out.println("Hello, " + name + "pleased to meet you");
    }
} 

但我明白了

Error: Main method not found in class String, please define the main method as:
    public static void main(String[] args)


推荐答案

如果您坚持使用String作为类名,则应为:

If you insist on using String as your class name it should be:

public class String {
    public static void main(java.lang.String[] args) {
        java.lang.String name;
        name = "luke";
        System.out.println("Hello, " + name + "pleased to meet you");
    }
} 

我认为尝试这样做并不是特别明智重复使用 java.lang 中定义的类的名称。

I don't think it's particularly wise to try and re-use the names of classes defined in java.lang though.

这篇关于Java Eclipse字符串错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆