gpt4 book ai didi

java - 相同的:没有输出

转载 作者:行者123 更新时间:2023-12-01 17:47:08 24 4
gpt4 key购买 nike

当我编译并尝试在 Eclipse 中运行它时,没有输出。我一直在尝试一切可能的方法。

class let {

String name;
int age;
int rollno;
}

public class class_method {

public static void main(){

let person1 = new let();
person1.name = "Ritwik";
person1.age = 14;
person1.rollno = 20;

System.out.println( " Hello my name is :" + person1.name);

Scanner s = new Scanner(System.in);
}
}

最佳答案

由于您的主方法的签名,您面临这种行为
在java中,main方法必须具有以下签名

public static void main(String args[]) { //Lots of code here }

了解更多详情,look here

更新

这就是为什么String[] args在主函数定义中很重要。以下是我已发布链接的 Oracle 文档的摘录

The main method accepts a single argument: an array of elements of type String.

This array is the mechanism through which the runtime system passes information to your application.

关于java - 相同的:没有输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53944270/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com