Java eclipse String Error

前端 未结 5 814
夕颜
夕颜 2021-01-19 10:16

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(S         


        
5条回答
  •  孤独总比滥情好
    2021-01-19 11:02

    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");
        }
    } 
    

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

提交回复
热议问题